I am attempting to schedule a cron job for database backups using percona extra backup.
My cron job is in cron.d and looks as follows;
exec &>/var/tmp/cron.log
1 * * * * * secondstory_prod /var/opt/backup/percona_xtrabackup_incremental.sh > /var/tmp/cron.log
The error i receive when i try and force the jobs to run in the log file listed above is /etc/cron.d/db_backup_daily: line 2: 1: command not found
If i try to run the jobs forcefully with run-parts /etc/cron.d i get the above error.
What is strange is that if i navigate to the directory and run the percona_xtrabackup_incremental.sh file it works with no issues.
Please can someone help?
Thanks
Your problem is you have one too many * in your cron entry.
1 * * * * * secondstory_prod ..stuff..
should be
1 * * * * secondstory_prod ..stuff..
will run on every 1st minute of each hour every day (above). The general time entry format is:
* minute (0-59)
* hour (0-23)
* day of month (1-31)
* month (1-12)
* day of week (0-6) (0=Sunday)
Related
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'm trying to set the cron jobs to run on a specific timezone, but I think I'm missing something.
I've tried to add TZ (And CRON_TZ) on top of the jobs in the /var/spool/cron/ file, but it doesn't seem to work.
TZ=Europe/Rome
* * * * * /usr/local/bin/php /home/user/folder/file.php
I've installed CWP7pro
from the manual:
Every * means something:
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
if you want every minute use this
*/1
example:
*/15 * * 1 * means every 15 minutes on the 1st day of the month
Edit /etc/crontab or use
crontab -e (edit)
CRON_TZ should be used instead of TZ or use TZ inline
*/15 * * 1 * TZ=Europe/Rome echo "do something"
I tried to set up the cron job any minute, I tried 3 different commands.
Any of them is not working.
Below is the error:
Run cron job every minute
The syntax is:
* * * * * /path/to/your/script > output
I have a php script which crontab executes every 30 minutes, during off-peak hours around 2-7am I don't get much traffic and so I wish to not run the script during these hours.
I'm not sure how to make a cronjob that will do this as I would find it hard to test.
The cronjob I have at the moment looks like this
*/30 * * * * /usr/bin/php /var/www/update/inv.php
*/30 0-1,8-23 * * * /usr/bin/php /var/www/update/inv.php
the range is inclusive, so 0-1 will do 00:30, 01:30, then 8-23 will do 0830 to 2330
ref: http://team.macnn.com/drafts/crontab_defs.html
You can restrict the hours you want the job to run.
*/30 0,1,7-23 * * * /usr/bin/php /var/www/update/inv.php
The times will be every 30 minutes until 0130. It won't run at 0200. The next run will be at 0700 and then every 30 minutes.
There's quite a good article here on how to set up the cron:
http://en.wikipedia.org/wiki/Cron
I want to run a php script every 10 minutes, between the hours of 9:30AM - 4:00PM
I googled before asking, and didn't have any success.
Anyone know how to do this? Or point me in the right direction?
Thank you
Try the following three lines in crontab
0,10,20,30,40,50 10-15 * * * # Every 10 minutes for the hours 10am - 3pm
0 16 * * * # 4pm
30,40,50 9 * * * # and 9:30, 9:40, 9:50
Run it from cron in every 10 minutes, check th date in PHP do nothing if it's outside the range.
*/10 * * * * /usr/bin/php /path/to/your/script.php