0

In my cron job file I have two cronjobs defined:

#Yo1 MAILTO="example@domain.com"
*1****wget -O - -q "http://example.com/cron/test1.php">/dev/null 2>&1
#Yo1 MAILTO="example@domain.com"
*15****wget -O - -q "http://example.com/cron/test2.php">/dev/null 2>&1
The PHP files are simple just sending mails with different subjects.

The issue is that both cronjobs are running on the same time every minute, but as you can see I want them to run on different times. First - every minute, second - every 15 minutes.

Can you help me with this. I can't figure out whats wrong.

1

According to manpage of crontab(5), you could specify lists (0,15,30,45) or steps (*/15).

So, you could use the following crontab entries :

#Yo1 MAILTO="example@domain.com"
* 1 * * * * wget -O - -q "http://example.com/cron/test1.php">/dev/null 2>&1

#Yo1 MAILTO="example@domain.com"
*/15 * * * * wget -O - -q "http://example.com/cron/test2.php">/dev/null 2>&1

Prefer 0,15,30,45 for portability instead of */15 * * * *.

-1

Cron only allows for a minimum of one minute. What you could do is write a shell script with an infinite loop that runs your task, and then sleeps for 1 seconds. That way your task would be run more or less every 1 seconds, depending on how long the task itself takes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.