Link to home
Start Free TrialLog in
Avatar of Jose Bredariol
Jose BredariolFlag for Brazil

asked on

cron and crontab problem

I´ve create this file : /home/user/rest.sh  (rwxr-xr-x).
------------------------------
#!/bin/bash
#rest.sh

shutdown -r now
-----------------------------

Edited the crontab file with crontab -e command.
inserted this line :

30 14 * * * /bin/sh /home/user/rest.sh

But the computer didn´t restart. What I´m doing wrong /
I´m using Debian Wheezy
Avatar of David Favor
David Favor
Flag of United States of America image

Keep in mind, this will only work in the root CRON file, never a non-super user account.

Only root (and other admin accounts) have privilege to run shutdown.
Avatar of noci
noci

Unprivileged user cannot do this,

either you need to use sudo (as an admin account) to run reboot /shutdown -r , or install this entry under the root user.
Also be aware that the regular path is NOT available in active cron jobs.

It is a good practice to qualify the command with full pathname.
shutdown is also in /sbin which might not be in the default path...
(You should receive a mail upon failure.)
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jose Bredariol

ASKER

Thanks all