How to make linux to reboot every day? - linux

I tried to use cron but I don't see it reboots - no one program restarts.
I wrote to my crontab -e
48 8 * * * sudo reboot
I tried to make it reboot every day at 8:48. Why it doesn't work?

Sudo? Try without sudo in root crontab.

Use sudo crontab -e and include "/sbin/" on your command "reboot.
48 8 * * * /sbin/reboot

Related

cron reboot after script

I want a daily backup, update and reboot on my raspberry pi (Raspbian GNU/Linux 9 (stretch) using a cron job.
So with root I use crontab -e and set the following jobs:
30 3 * * * /mnt/usb/backup/scripts/backup_daily.sh
00 3 * * * apt-get update
To update and backup a couple folders every day between 3am and 3:30.
Now after this I want to reboot the system. I know I can do something like
0 4 * * * reboot now
But I'm afraid that maybe my backup is still doing it's thing. Is there a way I can add a reboot job after my script has successfully finished?
At the last line of the backup_daily.sh put the reboot command.
and don't do it from cron.

Daemon cron not work

I am trying to use the deamon cron to add a command but didn't work.
I open the file /etc/crontab and I add the following sentence:
30 16 * * 1 root poweroff
But my system doesn't close. Please help me, I don't kow what I am doing bad.
Please, I would try the following...
sudo -i
crontab -e
Add the next line
30 16 * * 1 /sbin/poweroff
poweroff

How to reboot via cron on scheduled basis. Ubuntu 14.04

I have a very simple script that works from the command line.
#!/bin/bash
reboot
When I put a call to execute the script into root users crontab -e using the following format it does not run. It does run the first two commands, just that last one is giving me grief. I have no MTA installed as I do not need it.
*/10 * * * * service jwtpay restart
0 3 * * * bash /root/backup/mongo.backup.s3.sh kickass /root/backup >/dev/null 2>&1
0 */3 * * * bash /root/reboot.sh >/dev/null 2>&1
What am I missing?
Maybe the script is not executable... Since you use root's crontab why call the binary via a script and not the binary itself? Use the full path to the binary. It may vary on your system. Find out where it is with which reboot.
0 */3 * * * /sbin/reboot
Don't forget to restart the cron daemon, after changeing the crontab.

How to setup cron job on Amazon Linux AMI

I am hosting Tiny Tiny RSS site hosted on
Amazon Linux AMI
To update the feed automatically I have to run the following Cron job.
Reference
http://tt-rss.org/redmine/projects/tt-rss/wiki/UpdatingFeeds
*/30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet
Here is the step I did:
sudo su
cd /etc
crontab -e
# add this line
*/30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet
But I still got the message "Update Daemon is not running".
May I know, is this correct step for Cron job?
You should enter these commands on Amazon Linux 2:
sudo systemctl start crond
sudo systemctl enable crond
This sounds like crond is not running. In which case:
service crond start
chkconfig crond on
You should first inspect the cron log file /var/log/cron and look for any errors. This will probably give you the answer. Also make sure you can run the command successfully on the command line (/usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet).
Please check the spaces, it could be because of spaces are not placed correctly
Simply do : * * * * * wget -o - -q -t 1 "your url with cron file"
Please remove the "--quiet" part from your cron command and check the log and feed again

Using Cron to Reboot

I'm using a Raspberry Pi for a status display, but for whatever reason it gets incredabbly sluggish after a day or so of running so I wanted to reboot it every day so I setup a cron job to do that every morning at 8:50. But, it doesn't seem to be working. Is there anything special about using cron to do a reboot?
This is my crontab for the root user:
# m h dom mon dow command
50 8 * * * shutdown now -r >> /var/log/cron.log
0,30 * * * * date >> /var/log/cron.log
The second line works just fine, but I can't seem to get the restart command to work. It doesn't even output anything to the log.
Try using the fully specified path to shutdown. date may be in the PATH in roots cron environment, /sbin may not be looked up.
You need to edit the root user crontab
sudo crontab -e
then..
50 8 * * * reboot
Save and exit.

Resources