Results 1 to 5 of 5

Thread: Sudo in a user's crontab

  1. #1
    Join Date
    Aug 2011
    Beans
    Hidden!

    Sudo in a user's crontab

    Is there a way to set up a user's crontab to have a command that needs sudo and run, and not have it run in root's crontab (why it can't is irrelevant, just wondering if this is at all possible). On an extended note, running any command from a crontab that would require input of a password.

  2. #2
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Sudo in a user's crontab

    You can run it with gksudo instead of sudo if your system has X running. You will need to set the DISPLAY variable in your crontab to make it work. For text only, I don't think it can be done.
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Sudo in a user's crontab

    Just prefix the command with 'sudo' and make sure in your /etc/sudoers file (edit it via 'visudo') that you can run the specified command without the need to enter your password.

  4. #4
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Sudo in a user's crontab

    Quote Originally Posted by AlexC_ View Post
    Just prefix the command with 'sudo' and make sure in your /etc/sudoers file (edit it via 'visudo') that you can run the specified command without the need to enter your password.
    The question was not just about sudo, but in general any program that asks for a passowrd. Removing the need to enter the password kind of defeats the point.
    「明後日の夕方には帰ってるからね。」


  5. #5
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Sudo in a user's crontab

    Quote Originally Posted by Bachstelze View Post
    The question was not just about sudo, but in general any program that asks for a passowrd. Removing the need to enter the password kind of defeats the point.
    He wants to run a command as root but without placing the command in roots crontab; so he would need sudos default behaviour to run as root.

    Maybe I'm reading it wrong, but his question would be solved by my answer.

Bookmarks

Posting Permissions

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