1834832 Members
1968 Online
110070 Solutions
New Discussion

query about crontab

 
Rajesh G. Ghone
Regular Advisor

query about crontab

Hello all,

How do i schedule any jobs in cron??

Any answere will be appreciable.

Regards,
Rajesh G.
Rajesh Ghone
6 REPLIES 6
Michael Tully
Honored Contributor

Re: query about crontab

The man pages explain this:

Minute hour monthday Month weekday job

e.g.

15 1 * * 0 /usr/local/bin/fred

Runs a program called 'fred' at 1:15AM every sunday morning.
See this document
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B9106-90008/B9106-90008_top.html&con=/hpux/onlinedocs/B9106-90008/00/00/70-con.html&toc=/hpux/onlinedocs/B9106-90008/00/00/70-toc.html&searchterms=cron&queryid=20030529-225932

Regards
Michael
"When I have trouble spelling, it's called fat finger syndrome"

Anyone for a Mutiny ?
Con O'Kelly
Honored Contributor

Re: query about crontab

Hi
Use # crontab -e, make your entries and save.
If its a user other than root, ensure that they have cron access through editing /var/adm/cron.allow. Then as that user simply use crontab -e.
For info on specific fields in cron, see man cron.

Cheers
Con


Yogeeraj_1
Honored Contributor

Re: query about crontab

hi,

If you consider this simple cron script:

#*******************************************************************************
# min|hour |day |month|day |script |Logging Error and Output
# | |of mo| |of wk| |
#----|-----|-----|-----|-----|-----------------------------|---------------------
00 03 * * * /prod/allscripts/myscript.sh 1>/prod/allscripts/logfiles/output.log 1>/prod/allscripts/logfiles/error.log
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************

where the script i want to schedule is: /prod/allscripts/myscript.sh
and the output generated during execution is: /prod/allscripts/logfiles/output.log
and the error generated during execution is: /prod/allscripts/logfiles/error.log

you can schedule is either by:

1. editing the crontab table directly:
crontab -e

2. Loading the script from a file
crontab mycron.crn

For more information, do:
man cron
man crontab


if you any further queries, please revert.

hope this helps!

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Con O'Kelly
Honored Contributor

Re: query about crontab

Sorry typo above file is /var/adm/cron/cron.allow
Yogeeraj_1
Honored Contributor

Re: query about crontab

hi again,

also

to view the current crontab, do


crontab -l

I have attached the sample crontab as an example. Make sure that you make necessary modifications to /var/adm/cron/cron.allow (the List of allowed users)

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Massimo Bianchi
Honored Contributor

Re: query about crontab

Hi,
editing the crontab is usefull for scheduling jobs at regular intervals.


IF you weant to schedule job you can also use the

"at" command.

at -f /mysfiles.sh now


schedule a job for now,

at -l

showw jobs scheduled for start.

In the directory /var/spool/cron/ ypu can find the files where is stored the information for later start.

man at will give you much more infos.


HTH,
Massimo