Monday, February 26, 2018

Troubleshooting Cron (Cron not working)

I had a very curious case on a developmental server where after a couple weeks, I realized the cronjobs were not running. The crontab was fine, the scripts and permissions were fine and could be manually executed. Seems like the issue was cron itself.

It took a bit of digging, and there was this obscure line highlighted in the man page. Much thanks to here for pointing me in the right direction.
https://askubuntu.com/questions/23009/why-crontab-scripts-are-not-working

Two things were wrong here.

1. The crond was stalled. Quietly. Check this first and start it if it's stopped. Even if it's running, consider restarting the service.
service crond status
service crond restart

2. Crontab needs an empty/newline at the end of the file in order to load.
My version of crontab does not match the one in the article (I'm on CentOS 6); but the newline was missing at the end. Oddly enough all the other servers that were fine had this blank/newline. Guess it's pretty important, if not documented/deprecated.

At any rate, cron performs important user functions, so consider checking it from time to time.

--EOF

5 comments:

  1. try to rewrite the main part of the code, I have a similar situation, and after the error was corrected everything turned out

    ReplyDelete
  2. What's up everybody, here every person is sharing such familiarity,
    thus it's fastidious to read this webpage, and I
    used to pay a quick visit this blog daily.

    ReplyDelete
  3. AWS Training in Bangalore - Live Online & Classroom
    myTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.


    IOT Training in Bangalore - Live Online & Classroom
    IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.

    ReplyDelete
  4. Hadoop concepts, Applying modelling through R programming using Machine learning algorithms and illustrate impeccable Data Visualization by leveraging on 'R' capabilities.With companies across industries striving to bring their research and analysis (R&A) departments up to speed, the demand for qualified data scientists is rising.
    data science training in bangalore

    ReplyDelete
  5. Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it h
    as fewer syntactical constructions than other languages.python interview questions and answers

    ReplyDelete