Facing issues with cronjobs

Hello Everyone,

We have a cronjob scheduled to pick up files from one system and transfer to another system. the underlying code is a shell script. These cronjobs were working correctly until sometime. 2 days back they did not pick up the scripts but created empty logs. However when we tried running the scripts manually, they worked.

Can somebody suggest pointers towards the root cause?

Thanks!

Without way more info on the system and environment the jobs are running on/in, I think there's little we can do for you.
Did you implement any changes recently?

Given the information so far, ....................., um?? Where do we start?

Because the logs are being written, we can be sure that the cron part works, but is the log created by redirecting the output to a file in the crontab entry, e.g.:-

00 12 * * * /home/my_noon_script > /home/my_noon_log 2>/hom/myu_noon_errors

After than, can we see the code being called? If not, then we can't really advise you.

Robin

Did the shell script change between the time when it was working as a cronjob and when it started failing as a cronjob? (If so, what changed?)

Did something change on the system running the cronjob between the time when it was working and when it started failing as a cronjob? (New OS release installed? Networking failures reported on system console? ...)

Did smelting change on the system from which you are retrieving files between the time when the shell script was working and when it started failing as a cronjob? (New OS installed? Networking failures reported on system console? Change in the route used to connect the local and remote systems? Change in the permissions or ownership of the files being retrieved? ...)

To explain in more detail:

we have a schedule as below:

0 * * * * /file path/FileTransfers_IE.ksh 

This job runs every 1 hour and executes the above script. The above script in turn calls a series of scripts

transferFiles.ksh file1.config
transferFiles.ksh file2.config

transferFiles.ksh is the shell script which picks up files from source system using SFTP command, archives the file in local system and then sends the file to a target system.

Past few days the files are not sent to the target system and stuck in the middleware system. Upon investigating further found that the cronjobs are creating empty logs. Upon trying to run manually as below, the files are moved from source to target perfectly.

transferFiles.ksh file1.config

Today again the jobs worked and files were moved to target system.

So are you telling us that some days the cron jobs work perfectly and on other days they don't????? That is, this issue is intermittent?

1 Like

Please forgive me for being a little blunt, but you haven't shown us the code. It's a bit like ringing the garage to say "My car isn't working" and expecting diagnosis with just the hint that you turn the key. We don't know if the engine turns, if there is fuel or actually that the problem is a flat tyre.

Can you share your code and input files (sanitising any credentials) so we at least have something to consider.

When you run the code manually, is it as the same user account with the same environment set up? Be careful that the environment that a cron job runs with is usually very different to a login user unless you force it to match.

Robin