Linux, Tips and TricksLinux Cron not running ?

Linux Cron not running ?

There are 2 ways to set up periodic cron jobs in linux

  1. Put them directly in the crontab
  2. Put them in one of the cron directories – below are available

So you can create a script and put it in one of the directories and they will run according to schedule

For example, if i put a script in cron.hourly, it will be executed hourly etc

Before you do that, you have to take care of the below things

  • Make sure your script does not have an extension, else cron might ignore it. If you have a script named, just rename it to myScript
  • Make the script executable, use sudo chmod +x myScript
  • If using bash script remember to declare the #!/bin/bash at the top

Once you copy your script to the required directory, use this utility to test and see if cron will execute your script ( change cron directory as required )

sudo run-parts --test /etc/cron.hourly

Your script should show up here – else it wont be run

Categories: Linux, Tips and Tricks


No Comments Yet. Be the first?

Post a comment

Your email address will not be published. Required fields are marked *