I have a strange problem. I have a cron set up to check a database for a given date that is entered. If today's date matches the db recond, it supposed to change a value in a db table.
now, for some reason if the cron is set to go off every minute, it works like a charm. If it's set to a certain time, it doesn't fire at all.
(MYDOMAIN is set to the proper domain. )
works with:
* * * * * php -q /var/www/vhosts/MYDOMAIN.com/httpdocs/admin/scripts/includes/check_date.php
doesn't work with:
40 16 * * * php -q /var/www/vhosts/MYDOMAIN.com/httpdocs/admin/scripts/includes/check_date.php
or any variation of that time
any idea why it wont fire on anything else then every minute?
Check that your system time matches the timezone you are expect it to fire in by running
date
Did you try 59 23 * * * ? try the last minute of the day. Maybe the script only works late in the day ...
Related
I have a linux cron job to run. I want to configure its setting. What I have is, start_time for the job and interval after which it should repeat every time. interval is integer and has unit of day. So for example, I want to set up cron job starting on some random date in future and want to run that job periodically after every interval days. I tried to do 0 0 * * */interval but it does not give what I want. Any idea how to achieve it?
I think you may want something like
0 0 */interval * * /your/command
Basically switching day of week for day of the month. As for the random start date, that will have to be done somewhere else I think, like with a shell script which edits the cron file at a certain point etc.
EDIT:
This little script would allow you to edit the cron file.
#!/bin/sh
crontab -l > tempcron
echo "00 00 * * * /bin/ls" >> tempcron #just an example cron
crontab tempcron
rm tempcron
I am able to schedule using this cron expression using nodejs cron-job every one hour (starting from "now").
But I need to set q cron every one hour starting from a specific time. E.g let's say starts from 3:30 AM. can this be done?
The / character allows you to give two expressions to a cron part. The first is a "starting at" argument and the second is "every X units". So, a cron that will run every hour, starting at 03:30 (I.e., at 03:30, 04:30, 05:30, etc.) would look like this:
0 30 3/1 * * * *
You can try this:
30 3/1 * * * * *
Just to add to Mureinik's answer, just "starting at" on the first argument is non-standard and it may not work with every cron. The standard format should be
startingAt-endingAt/forEvery
example: 30 3-23/1 * * *
I'm trying to write a cron job to run automatically a PHP file after 30 days. The PHP file has write permission 777.
Here is my code:
* * * */30 * php -f /var/www/virtual/my_domain_name.com/htdocs/./file.php > /dev/null 2>&1
But this is not working, I got no errors.
When i try:
* * * * * php -f /var/www/virtual/my_domain_name.com/htdocs/./file.php > /dev/null 2>&1
The script works, then it executes the file every second from.
Any ideas?
Putting */30 in the 4th field would cause the job to run only in the 30th month of the year, and every 30 months thereafter during the year -- i.e., never.
Putting */30 in the 3rd field (day of month) would cause it to run on the 30th day of each month (and on the 60th, 90th, ... day of the month if there were such a thing). And given the *s in the other fields, it would run once a minute on that day -- and never in February. I doubt that that's what you want.
If you want a job to run once a month, that's easy:
0 0 12 * * php ...
This will run the job at midnight on the 12th day of each month. Adjust the first two fields to pick a different time and the third to pick a different day.
There is no syntax for running a job once every 30 days. If that's really what you want, you can schedule the job to run once every day:
0 0 * * * php ...
and then have the job itself determine whether the current day is a multiple of 30.
i was trying to make a code to automatically send mails from a server. I want it to run a php everytime at every hour and 15 minutes and 30 minutes.
Example at 08:15, 08:30, 09:15, 09:30, etc..
Thank you,
Daniel!
How about this?
15-30/15 * * * * * php foo.php
Obviously, replace php foo.php with the command you'd like to run. The 15-30/15 syntax indicates: minutes 15 through 30, with increments of 15. This will make your job run every hour at xx:15 and xx:30.
I am using Quartz Scheduler using Spring. I want to configure the same with following schedule:
Run Job Every 10 minutes starting NOW
I am using following expression for the same.
0 */10 * * * ?
I thought * in the minutes field would make it run the first minute, but it does not do that way. It runs the first 10th minutes from now and then every 10 minutes afterwards.
Can anybody please suggest me the reason for this behavior and the solution to my problem also?
0 0/10 * 1/1 * ? *
Please see : http://www.cronmaker.com/
check the minute your at now and add them as a list to your crontrigger. if you start the trigger at minute 12 for example add
0 2,12,22,32,42,52 * * * ?
as your cron expression
Edit:
Another solution would be to define a simpletrigger that repeats every ten minutes
SimpleTrigger trigger = new SimpleTrigger("myTrigger",
null,
new Date(),
null,
SimpleTrigger.REPEAT_INDEFINITELY,
10L * 60L * 1000L);
You can use something like
0 1-59/10 * * * ?
That will trigger the job at any minute and 10 minutes after that. I didn't try it but it looks right. :)
*/10 * * * *
Every 10 minutes starting from the moment you create the cron job, wether you prefer (user crontab, /etc/cron.d/, ...).