1

I have 50+ cronjobs like the one given below running in my Centos 7 server. curl -s https://url.com/file.php

This runs every 10 minutes. When running manually from the shell it only takes 1-2 minutes. It also is working fine using cronjob. The problem is that it does not exit after the execution. When i check my processes using ps command, it shows many cronjobs of previous dates(even 10 days before) which accumulates the total proccesses in my server.

Line in crontab :- */10 * * * * user curl -s https://url.com/file.php > /dev/null 2>&1

Is there any reasion for this? If i rememmber correctly this happened after latest patch update. Please help.

1 Answers1

0

Modify your command to store the logs in log files instead of dumping it to /dev/null.

Options

  • --max-time
  • --connect-timeout
  • --retry
  • --retry-max-time

can be used to control the curl command behaviour.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
  • I tried it, but the problem is the same cronjob is not getting stuck everytime. Its different. And as i said, the job is executed successfully and i get the result needed when writing to a file. It isnt exiting after the job is completed. – Farhan Faiz May 29 '21 at 20:21
  • In your crontab line, what is the "user" thing? It should only be `*/10 * * * * curl -s https://url.com/file.php >/tmp/out1 2>/tmp/out2`. With the /tmp/out? files, you will see all messages. If the cron execution does not complete, it means your curl command does not exit. Hence he extra parameters to make sure it timesout. Or there is another problem, which we cannot find without logs. Look at your cron logs as well. Look at https://stackoverflow.com/questions/4883069/debugging-crontab-jobs#34872041 for the details. – Nic3500 May 30 '21 at 03:50
  • Worst case, create a script that first kills all the "stuck" curl, then start a new one. This way at least you will not accumulate zombie curl. – Nic3500 May 30 '21 at 03:53
  • the user in cron line tells as which user it should run the script. And i tried writing the output to temp file, but it only has the result which will be shown when doing it manually from the terminal. I have cron logs and that too shows that the cron is executed without any errors. Looks like i should use the timeout option until i find the cause of this. – Farhan Faiz Jun 01 '21 at 18:49