How to give a random delay on Cron Jobs commands - cron

I have tried a couple of suggestions but always failed.
I want to get a php file runned almost every minute, for this I am using the command:
* * * * * wget http://link.php
How can I give that command a random delay?
For example,
1st time : working in 65th second
2nd time : working in 67th second
3rd time : working in 72nd second

Related

Azure Function CLI irregular trigger timing and wrong details

I m testing Azure function locally using cli.
I have noticed 2 issues:
Sometimes CLI do not shows correct time when function will be executing. For example I have cron to execute function every two mins but it shows function will be executed after a difference of seconds ? weird.
Often it do not starts execution as per time shown in CLI, few times it took much time and then respond.
Is is normal ? Please guide how I can fix these.
try [TimerTrigger("0 */2 * * * *")] see examples here
* */2 * * * * cron expression means that you want to execute it every second (the first *) of every 2nd minute, so
2:50:00
2:50:01
2:50:02
...
2:50:59
2:52:00
2:52:01
etc
The correct expression is 0 */2 * * * *: execute every 2nd minute when seconds are 0, which should give
2:50:00
2:52:00
Please check if you still have delays after this change, and it so, post it as a new question with exact description of the problem.

Understand the meaning of Crontab timing

I am trying to understand the crontab timing for the following :
00 */2 * * *
if I understood correctly , this runs every half hour , right ?
From crontab manual
Step values can be used in conjunction with ranges. Following a range with "" specifies skips of the number’s value through the range.
For example, "0-23/2" can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is
"0,2,4,6,8,10,12,14,16,18,20,22"). Steps are also permitted after an asterisk, so if you want to say "every two hours", just use "*/2".
This runs every two hours.
0 */2 * * *
Following runs every 30 minutes,
30 * * * *

cron expression for every hour starting from specific time

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 * * *

set cronjob time

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.

cronjob not working

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 ...

Resources