Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2513

General discussion • Re: Reboot using crontab

$
0
0
@thagrol
Thank you. I need to read your response carefully but with regard to your first point, the command I have entered into cron is in the same cron file as the commands that take the picture at 10pm each night and that runs fine every night.

I'm afraid that tells us very little. shutdown, reboot, and related commands can only be run by root or with sudo.*

You have options:
  1. Attempt to debug you existing crontab entry:
    1. Change it to

      Code:

      0 21 * * * /sbin/shutdown -r now 2>/home/username/reboot.log
      Replace username with your actual username.
    2. Wait until the scheduled job should have run
    3. Examine the contents of 2>/home/username/reboot.log. Any errors occuring wwill be in there instead of being throw away.
      If it's empty, either no errors were produced or it succeeded (you can check by examing the output of uptime)
  2. Try adding sudo to your crontab entry. This will fail if your user does not have permission to use sudo or if they are required to enter thier password when using it.

    Code:

    0 21 * * * sudo /sbin/shutdown -r now 2>/home/username/reboot.log
  3. Remove it from you user's crontab and add it to root's:
    1. Code:

      crontab -e
    2. Remove or comment out the line.
    3. Code:

      sudo crontab -e
    4. Add in your original line. You do not need to include sudo.

My gut feeling is that this isn't a cron problem or a shutdown/reboot command problem. It's you trying to run those commands as a normal, unprivaliged user. The above is a slightly more detail version of what I said in my previous post in this topic.

*: In widows terms that's as an administrator or with administrator rights.

Statistics: Posted by thagrol — Wed Mar 06, 2024 2:01 am



Viewing all articles
Browse latest Browse all 2513

Trending Articles