Avatar of Jose Bredariol
Jose Bredariol
Flag 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
LinuxOperating Systems

Avatar of undefined
Last Comment
Jose Bredariol

8/22/2022 - Mon
David Favor

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.
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
David Favor

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jose Bredariol

ASKER
Thanks all
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck