Changing the CronTab Editor from sed to your desired one and Add Cron Jobs to Server

Summary: Most of the time newbie install the cron and accept the terminal editor sed for crontab, which brings them towards difficulties.
In this Tutorial we have shown that how to change the CronTab Editor from sed(default Crontab Editor) to your desired one, like VIM,GEDIT,NANO or VI.

Follow the Procedure given bellow will guide you  to add jobs to cron successfully.

Step-1. Login to your server through ssh Press(Alt+Ctrl+T) open terminal
root@pfserver-desktop1# ssh ( you can use IP instead of

checkout your cron is installed
root@pfserver-desktop# ps -aux
: if no entry is there for cron then

Step-2. Start your cron service

/etc/init.d/cron start or service cron start

Step-3. Now type the command on your terminal

root@pfserver-desktop# env EDITOR=vim crontab -e
It will open a file of crontab for you where you can add your jobs.

Now we want to add some jobs to our crontab file.

1: First you have to write a shell script or txt file and save it on your server in a known location

2: shell scrip is saved with the name of

3:root@pfserver-desktop# chmod +x
To operate as script file

4: After creating a file test it manually wither it is running correctly or not.
like i have created file in /bin directory so i will check it manually

5: root@pfserver-desktop#/bin/ daily

The output is :
SARG – Daily / Weekly / Monthly – Squid proxy usage reports creation tool
Written by Imran Ullah <sysadmin@……..>
Version: 20050202
Usage: /bin/ [OPTIONS]
Allowed options:
manual, Create Manual report
today, Create Today report
daily, Create Daily report
weekly, Create Weekly report
montly, Create Monthly report
SARG: No records found 20039, reading: 99.81%
SARG: Records in file: 20039, reading: 100.00%

Now i am adding this script to crontab file. Where in the above command the daily is used as an argument to run the script.

Step-4 :root@pfserver-desktop# crontab -l
no job for root user

Step-7: root@pfserver-desktop# env EDITOR=vim crontab -e

# Edit this file to introduce tasks to be run by cron.
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use ‘*’ in these fields (for ‘any’).#
# Notice that tasks will be started based on the cron’s system
# daemon’s notion of time and timezone.
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# For more information see the manual pages of crontab(5) and cron(8)
# m h dom mon dow command

Step-8: Press i for insert and type the following command

01 20 * * * /bin/ daily
10 20 * * 1 /bin/ weekly
20 20 29 * * /bin/ monthly

Save and Exit!

Setp-9: Check out your crontab

crontab -l
This will show you the jobs you added to crontab file.

Step-10: First line in the jobs added to crontab file the figure 01 means every minutes, 20 means 8:00 P.M, and the * means all the times, So this script will be executed every day, Each month and in Every week at 8:01 Evening, And the out put directory is defined in the file.

Step-11: In second line the 1 is used for Monday (week: Sunday =0..6) so on every Monday at 8:01 P.M This script will run and produce the out put.

Step-12: In third line 29 means Date of the Month. This will create out put on Every 29th of the month at 8:01 PM at any day of the week every year.

Step-13: restart the service of cron for confirmation that there is no error in the new posted jobs.

service cron restart
restart OK

now can ENJOY the a cup of TEA at 08:01 * * *! Have a nice day.

Leave a Reply

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