cron jobs are not running in cPanel/WHM

Dear experts,

I have a VPS account with hostgator and created some scripts under crontab. Somehow my scripts are not running at the scheduled time. I've ensured that my script runs simply typing the command ./ and it does update my online database. I've also noticed the path with jailshell on top of the crontab when I input crontab -e. I am wondering if my scripts are been locked?

If locked how can I resolve it by either manipulate with the settings in cPanel or WHM that will not lock my scripts? Thanks
Kinderly WadeprogrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you share sample script that you schedule to run with crontab?

When you write script to run under crontab, then consider:

1- set env variables that script needs, e.g. PATH
2- user full pathnames to folders and files
3- Redirect stdin, stdout & stderr as required
4- Make the script file executable (use chmod)
Kinderly WadeprogrammerAuthor Commented:
Hi omar,

I found the issue. When I typed ps -ef and looking for my bash script named, I found this line:

jailshell (loginname) [14313] -c /home/loginname/script/

I assumed that somehow the script got locked up? (I have a loop in this script that loops every 5 second checking for update. It simply will read the mod date of a particular file. If the date change the script will copy that file over).

Can this be due to overloading the system? What can be the fix for this if I need to keep the update every 5 second?

all my other scripts are running fine. I have a script that will do the backup on an hourly base (works fine).
To avoid any overlap between cron jobs, you can do the following:

1- create a lock file:

touch /tmp/mylock$$

2- check if more than one lock is there

c=`ls /tmp/lock* | wc -l`

3- if $c is 1 then do what you want to do else do nothing

4- remove your lock

rm /tmp/lock$$

In this way you can avoid overlap of cron jobs
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Kinderly WadeprogrammerAuthor Commented:
Hi omar,

How can I be 100% sure that crontab is running my bash script? Thanks
You can log the run, e.g. put command like below as first line in the script:

/usr/bin/date >> /tmp/mylog (please verify path for date command)

And later check the content of /tmp/mylog file. If you see dates in the file then the cron job run otherwise not.

You could also run the bash script in verbose mode and log the execution to a file. This can be done with

 bash -x scriptname >> /tmp/myscriptlog

Do you have ssh access to the server? This can give you a way to check other logs for crontab or mail since cron will send mail to the user if there is an error in running the script.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mohamed MagdyCTOCommented:
In cPanel, you can find cronjob logs here:


Open in new window

Could you please provide the result of this command?
egrep -i '' /var/log/cron

Open in new window

change with your script name.
If your server have issue, I use a cron service called to trigger the script to run.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.