Find the answer to your Linux question:
Results 1 to 5 of 5
I just started working with shell scripts & crontab. A tutorial for shell scripts was very useful. Another fro Cron jobs seems equally simple & straight forward, but I must ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    3

    Help with Crontab

    I just started working with shell scripts & crontab. A tutorial for shell scripts was very useful. Another fro Cron jobs seems equally simple & straight forward, but I must be missing something obvious.

    Basically, my crontab looks like this. I want the computer to reboot at 3:35 PM daily. However, when the time comes, it doesn't actually reboot. Or do anything else. When I set it to a path of a shell (IE /etc/cron.d/shutdown.sh) it also does not do anything.

    Code:
    # m h dom mon dow   command
    35 15 * * * sudo shutdown -r 0
    Can someone tell me what I missed?

  2. #2
    Just Joined!
    Join Date
    Jun 2010
    Posts
    3
    I just saw the e-mail that is sent to /var/mail/zoneminder. It says
    Code:
    [sudo] password for zoneminder:
    I guess in the case of rebooting the server, I need to create a shell script & pass it the password on the next line? It seems a little unsafe!

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    3

    Bump

    Bumpety bump bump

  4. #4
    Just Joined!
    Join Date
    Jun 2010
    Posts
    1
    push ur ssh keys to /root/.ssh

    ssh root@localhost "shutdown -r 0"

  5. #5
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,303
    To run a root level crontab you must edit the root users crontab

    run
    Code:
    sudo crontab -e
    and add your command in there

    Code:
    # m h dom mon dow   command
    35 15 * * * shutdown -r 0
    You may need to add
    Code:
    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    as the first line in the crontab file.
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

Posting Permissions

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