Find the answer to your Linux question:
Results 1 to 2 of 2
Hi,. I need to run a script in crontab. It needs to have all the user's logon profile (su -) but when I run in cron as: su - user ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3

    How to "su - user -c" in the same user for CRONTAB

    Hi,.

    I need to run a script in crontab.
    It needs to have all the user's logon profile (su -) but when I run in cron as:

    su - user -c "command"

    it don't work (asks a password)...

    any idea?

  2. #2
    Just Joined!
    Join Date
    Aug 2008
    Location
    Columbia, TN
    Posts
    14

    How to "su - user -c"

    TRY : su -l user -c "command"

    And I think you must be root in order to be allowed to use su in the scripting format in this manner. Just like on the command line, root can su to someone without a passwd. Going in the other direction from user to user will always require a passwd, unless you take the passwd out of the passwd for the user being su'd to.
    From user to root via cron is a security breach. I believe it was still available in the late 1980's on SUN version 2 or 3, before Solaris, before the internet existed.

    Another idea: How about a dummy user that has the cron script in question launched from etc/passwd . The shell has to be defined in /etc/shells along with all other valid shells.

    Or add a crontab for the user in question and it runs under user in question with out the su.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...