Home > Linux, Tips and Tricks > Linux 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 myScript.sh, 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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: