I recently discover crontab on my raspberry pi and I wanted to try it so I made different lignes for execute simples programs:
$
0 21 * * * /home/pi/Desktop/Programmation/Batch/msg.sh
30 21 * * * /home/pi/Desktop/Programmation/Batch/msg2.sh
0 22 * * * /home/pi/Desktop/Programmation/Batch/msg3.sh
15 22 * * * /home/pi/Desktop/Programmation/Batch/msg4.sh
30 22 * * * /home/pi/Desktop/Programmation/Batch/msg5.sh
35 22 * * * /home/pi/Desktop/Programmation/Batch/msg6.sh
(I know: it's not batch but sh !!)
Here is the .sh program (there are all the sames):
#!/bin/bash
echo -e "Hello World !"
sleep 1000000000000000000
But that's doesn't work !!
I look on internet and I tried to change the TZ of crontab, I tried the command timedatectl to verify mi date settings :
Local time: sam. 2020-10-10 18:23:37 CEST
Universal time: sam. 2020-10-10 16:23:37 UTC
RTC time: n/a
Time zone: Europe/Paris (CEST, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
And That doesn't work... So please help me !! Thank you very much !!!
I have some cronjobs written on several servers using CentOS7 in combination with Plesk 18.
When I check my cron log I see that the cronjobs are started.
Even when I manually start the scripts I want to use they work, but for some reason when the crontab does it, nothing is happening.
For instance some of the cronjobs I have are:
MAILTO=support#shoptrader.nl
0 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/remove_files.sh
0 6 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/security_htaccess/security_htaccess.sh
15 7 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_personal_files.sh
30 9 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_hacks/find_hacks.sh
*/5 * * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh
15 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_templates_data/backup_templates_data.sh
If I check my log I see something like: Jan 14 09:30:01 web14 CROND[4402]: (root) CMD (sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh)
I've notified myself with e-mails and get this response
/var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh: line 12: php: command not found.
Which doesn't make sense, because PHP is working on the server.
I have to run task which take time 3 or 5 minut
How to run multiple task in crontab -in same time ?
crontab -e
0 13 * * * /etc/rip_first_radio.sh
0 13 * * * /etc/rip_second_radio.sh
0 13 * * * /etc/rip_third_radio.sh
0 13 * * * /etc/rip_fourth_radio.sh
your crontab config is correct. But you can add add all into one script and run also.
vi main.sh
./etc/rip_first_radio.sh &
./etc/rip_second_radio.sh &
./etc/rip_third_radio.sh &
./etc/rip_fourth_radio.sh &
and add main.sh to cron.
0 13 * * * ./main.sh
I have 2 crontab commands.
The cron below works fine:
00 19 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare
The cron below does not work after I add the time behind:
05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/'date +%Y%m%d%H%M%S'cyn.in-disk1.vmdk
Please guide me to understand the command and how to solve.
You should enclose the date command with ` instead of ' and escape the % characters
Try this:
05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/`date +\%Y\%m\%d\%H\%M\%S`cyn.in-disk1.vmdk
Partly using stackoverflow search I figured out how to run my cronjob every 3 hours but not between 23h-16h. That means a pause between 16h today untill 23h today. So the cronjob should start running every 3 hours at 23h and stop at 16h, then start again at 23h.
This is the result:
0 23-16/3 * * * /usr/local/bin/flexget -c /media/usb/Downloads/flexget/config.yml --cron
Now my question: Why is this not working? It does not run at all :(
I also tried:
* 23-16/3 * * * /usr/local/bin/flexget -c /media/usb/Downloads/flexget/config.yml --cron
(not sure what the difference is with 0 or with * for the minutes, rounded hours or not?)
This DOES work:
0 */3 * * * /usr/local/bin/flexget -c /media/usb/Downloads/flexget/config.yml --cron
But then it just runs every 3 hours every day, without pause between 16-23.
You can always list the hours explicitly.
0 2,5,8,11,14,23 * * * /usr/local/bin/flexget -c /media/usb/Downloads/flexget/config.yml --cron
Note this is not the same as with replacing 0 minutes with *, like:
* 2,5,8,11,14,23 * * * /usr/local/bin/flexget -c /media/usb/Downloads/flexget/config.yml --cron
The latter starts on every minute on the hours specified, i.e. 2:00, 2:01, 2:02, ..., 2:59, 5:00, 5:01, ... 5:59, ...