Setting up Cronjobs on Linux

Hello, When it comes to scheduling. We ofter find this ‘Cron’ word into the Server world. But, Cronjobs are very initiative way available in Linux to schedule something. We will start with basic details and then move commonly used snippets.

Scheduling Basics:

Simply hit, crontab -e in your linux terminal. It will ask for your easier editor to work.

You will find a few asterisks then Linux command. This is the part where we are setting up the scheduling. So, Normally, there are 5 asterisks followed by the command which you want to run. For example, I am setting up an hourly reminder notification in Ubuntu.
Note: In your case, notify-send might be unavailable.

In above command, We set the linux notification command to run each hour at 0 minutes. Now, What if I want to run if every 30 minutes. Then rule is simple, We will replace 0 with */30 or you are open for you requirement. you can make

i.e Every Five Minutes ( */5 * * * * )

What if we want run only once in a day. So, you will change the hourly bit to 0 or whatever the hour you want to run

ie. Once in a day ( 0 7 * * * ), we clocked it to run every 7:00am every day. Please notice the timings are in 24 hour format.

Brainer: Now, question is why it doesn’t followed minute suit. ie ( */5 ) for every five minute.

Hint: Because, We are guiding to run on only once in a day. Not after every 7 hours. You can same with minutes.

Setting Cron for Website

For a website, you have two option. But you need to make sure commands are available before placing it in cron.

For Example, changing wordpress to server cron. We will do like

Or you can use wget

Previous Post
Handling Cookies in JavaScript
Next Post
WooCommerce Shortcodes with qTranslate

No results found.

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.