cancel
Showing results for 
Search instead for 
Did you mean: 

Editing the cronjobs

Mehul5
Frequent Advisor

Editing the cronjobs

Hello Everyone,

 

Can anyone please tell me how can I make some entries in cron if I have to make some process automated.

 

Like I want that the nickel script should run daily or on weekly basis and a script containing some imp commands like

 

ioscan, bdf. cmviewcl, etc should run daily in the morning and evening.

 

Please suggest how can I do it and where I have to edit.

 

I don't want ready made script as I have to learn how to do it I want the procedure or anything related to it in a basic form.

 

Since I am new to hpux I want to know about unix.

 

Please also guide me in any way possible.

 

Regards,

Mehul

1 REPLY
Patrick Wallek
Honored Contributor

Re: Editing the cronjobs

To edit a crontab file you use 'crontab -e'.  This will open your crontab file in the 'vi' editor.

 

From there you add entrires in the following format:

 

<min> <hr> <monthday> <month> <day of week> <command to run>

 

The explanation of each field from the 'crontab' man page (remember that man pages are your friend):

 

      The entries in a crontab file are lines of six fields each.  The
      fields are separated by spaces or tabs.  The lines have the following
      format:

           minute  hour  monthday  month  weekday  command

      The first five are integer patterns that specify when the sixth field,
      command, should be executed.  They can have the following ranges of
      values:

           minute         The minute of the hour, 0-59

           hour           The hour of the day, 0-23

           monthday       The day of the month, 1-31

           month          The month of the year, 1-12

           weekday        The day of the week, 0-6, 0=Sunday

      Each pattern can be either an asterisk (*), meaning all legal values,
      or a list of elements separated by commas.  An element is either a
      number in the ranges shown above, or two numbers in the range
      separated by a hyphen (meaning an inclusive range).  Note that the
      specification of days can be made in two fields: monthday and weekday.
      If both are specified in an entry, they are cumulative.  

 

For example, if you want to run a script called "dosomething" that is in the /do/it/now directory at 3:15 AM every Wednesday morning you crontab would like like:

 

15 3 * * 3 /do/it/now/dosomething

 

Read through the crontab man page for more explanations.

 

# man crontab