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.
Related
I've modified the crontab with:
sudo crontab -e
and added a cron for a script to run every minute so I can test if it works:
1 * * * * /scripts/backup-script.sh > /scripts/backup-script.logs
Afterwards, I tried to restart the cron service to restart the server but the cron doesn't seem to be working, I tried to use:
crontab -l
and it appears to have the old content as if I didnt even modify it. However, going into crontab -e does show the updated content.
To make your script run every minute your cron record must be:
* * * * * /scripts/backup-script.sh > /scripts/backup-script.logs
What you enter will run every 1st minute every hour
And if you add record via crontab command you do not need to touch cron daemon
To see the cron record you add with sudo crontab -e you must check it with command sudo crontab -l. Otherwise you list cron record of different user
I have configured cron job but it's not working.
I wanted to run the myfile.sh script for every 2 mint and below are my configuration in crontab.
# m h dom mon dow comman
2 * * * * /home/ubuntu/myfile.sh
myfile.sh is executable and contains below lines of code
#!/bin/bash
mysqldump -u[user] -p[password] --single-transaction --routines --triggers --all-databases > /home/ubuntu/backup_db10.sql
Is there anywhere we need to add configure anything?
You're running the script at two minutes past every hour. As in 1:02, 2:02 and so on.
You can change it to something like
*/2 * * * * /home/ubuntu/myfile.sh
to run it every two minutes.
A bit more info can be found here.
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.
I need to create a new crontab job in a Redhat Linux environment. I have sudo access to that but I don't think I can do everything on that system--some higher level sys admins, for example, disable any firewall changes I make.
So here is my crontab command:
crontab e
and that brings up a screen like:
33 2 * * * /usr/bin/cu-firewall update > /dev/null 2>&1
30 1 * * * /root/update_atbi_website > /dev/null
0 4 * * * /home/prov356/scripts/opnforumbackup
I want to not send email and I have done it successfully in my local VM:
MAILTO=""
# execute 15 minute
*/15 * * * * perl /db_xenia/pl/get_usgs.pl
Question: If I were to append the above to the existing crontab info will it prevent sending of emails to the sys admin too? I don't want to get into trouble! Perhaps, I could append /dev/null after my Perl commands?
Thanks.
Never mind: Per #Basile's comment, I didn't need to be sudo. So I logged in as non-sudo and ran crontab -e; this time there were no sys admin entries. So I simply entered my own configs, saved, and the cronjob seems to be running fine.
Thanks.
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.