0

I'm recording entries into crontab using PHP (www-data user). The first entry is a scheduler that runs every minute. If the scheduler finds a specific criteria it adds new entry to crontab. After I add an entry, the scheduler (that should run every minute) stops working. The cron jobs aren't running in parallel. It is like the www-data user could only execute a single cron job.

My scheduler, which works when it's the only thing in the crontab:

* * * * * curl --silent http://myapi_url/scheduler >/dev/null 2>&1

When the scheduler runs, it adds a new entry:

18-59/2 * * * * curl --silent http://myapi_url/user/10 >/dev/null2>&1`

So the new entry works, but the scheduler stops working. If I add yet another new entry, the two previously added stop working but not the new one. Why?

EDIT:

The crontab looks like this:

* * * * * curl --silent http://myapi_url/scheduler >/dev/null 2>&1 
18-59/2 * * * * curl --silent http://myapi_url/user/10 >/dev/null 2>&1

each new entry comes below.

  • Because you are doing it wrong .. what are the content of your crontab after adding the second entry ? What command are you using to add the second and following entry to crontab ? – Soren A Jan 24 '18 at 18:59
  • @SorenA I edited my answer. – Alexandre Pinheiro Jan 24 '18 at 21:52
  • Please use either four spaces at the beginning of a line or the {} button in the editor to format blocks of fixed-width text. – Chai T. Rex Jan 24 '18 at 23:40
0

I found the problem. When writing to Crontab I was using the line break incorrectly and due to this at the end of the entry a ^M was recorded.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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