We help IT Professionals succeed at work.

cron and crontab problem

Jose Bredariol
on
101 Views
Last Modified: 2019-02-05
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
Comment
Watch Question

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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.
nociSoftware Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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.)
Fractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thanks all

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions