Strange issue with cron job

General support questions
Post Reply
ikanchev
Posts: 2
Joined: 2023/07/17 16:39:28

Strange issue with cron job

Post by ikanchev » 2023/07/17 16:52:08

Hi all, i hope someone can advise on a strange issue i am having with one simple cron job.

So i create the job to run every 1 hour and that is all fine. The job triggers via root account and executes a python script.

When i run the python script via sudo manually it goes from start to finish without issue. When it runs from the cron job however it seems to always stop at ~5 minutes of it's execution.
I have tried adding timeout in front of the python call, but then the job doesn't start at all.

User avatar
TrevorH
Site Admin
Posts: 33230
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Strange issue with cron job

Post by TrevorH » 2023/07/17 17:54:38

There is no time limit on cronjobs.

I would make sure that you have both stdout and stderr from the job redirected to files so that you can see what it says. So along the lines of

0 * * * * /usr/local/bin/mycron.sh >/var/log/mycronout.log 2>/var/log/mycronerr.log
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ikanchev
Posts: 2
Joined: 2023/07/17 16:39:28

Re: Strange issue with cron job

Post by ikanchev » 2023/07/18 08:50:32

Thank you sir! This helped me understand where the script fails. Still wonder why it passes through when executed manually though.
Anyway i made slight change to the script and the cron job runs ok now.

Post Reply