Program not running from the cron scheduler

Good Afternoon,

I have a sh script that the admin added to the cron schedule.
It runs fine when I run it manually...but not when scheduled.

I added the path that is found for my user to the script. Still no luck.

Any ideas what I should look at?

Thanks
Marty

This is one of the most common questions on this forum. Please search the forum for answers; you will find a very large number of them.

Basically, the run-time environment between manual running and cron is NOT the same and you need to discover why. Setting of variables, full pathnames, etc.

Just search this forum and keep reading. All the answers are here.

Thank You. I should have done that first.

You're welcome. If after that you are still stuck, post the script on this thread and someone here will very soon tell you what the problem is. Don't waste too much time on it if you can't see it, post the script here.

I will just post the script contents here.

I am such a newbie to this...it is probably something blatantly obvious to experts.

PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/gl-cli-user/bin:/usr/java/jdk1.6.0_91/bin:/usr/ant/apache-ant-1.6.2/bin:/usr/local/lib

cd /home/gl-cli-user/

current_date=$(date +%m/%d/%Y) 

echo $current_date

nohup ./ledger -comptroller_extract $current_date &

Nothing obvious.
Any log file entries? Any error messages? Mayhap sent by mail (you may want to redirect stderr to stdout in the crotab entry). Did you see the echo $current_date output? Add another echo to the end of the script.
Does it wait for interactive input?

Another thought is are you using the same user account to test the script manually as set up in cron?

If not, the access rights may not be set up to allow the cron user to run/access, therefore creating an error in cron that you don't see when running from the command line.

why are you using nohup? I don't see the purpose in spawning a background process.

1 Like

Please verify that your script has executable permission. Also, make sure you can run it outside cron.