Operating System - HP-UX
1833189 Members
3060 Online
110051 Solutions
New Discussion

How to shedule the job in crontab

 
musaddaq_2
Frequent Advisor

How to shedule the job in crontab

Hi
I need to make a crontab that executes a script every night at 10 pm.
the parameter will be 00 22 * * *.
But i dont know in which file i need to pass these parameters and how to execute it.
I have made a man of crontab and cron, but it doesn't explain it.

Thanks in advance.

Regards

Musaddaq
8 REPLIES 8
melvyn burnard
Honored Contributor

Re: How to shedule the job in crontab

you create a new file, edit it to conatin the entry you require, then use the crontab command to read that file and schedule it.
SAM might be an easier method for you.

Be aware that if you already have cron jobs configured, you need to preserve those and include them in th efile with your new request.
This can be done by doing crontab -l > yourfile,
then edit this file adding in your job, and resubmit the whole config with crontab yourfile.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Leif Halvarsson_2
Honored Contributor

Re: How to shedule the job in crontab

Hi,

If there already is jobs in your ctontab, do a:

crontab -l >file

Then, edit the file (add your new job).

crontab
Check that everything is OK with:

crontab -l
Stefan Schulz
Honored Contributor

Re: How to shedule the job in crontab

Hi,

you can use sam to edit this crontabfile. This gives you some help in editing also.

Alternatively you can use the crontab command. Login as the user you wish to run the command as (eg. root).

Do a crontab -l to list all current cronjobs for that user. Than use crontab -e to edit the crontabfile. You don't have to know the location of the crontab file. Edit the corntabfile to your needs and save and exit the file.

The crontab command will take care of the rest.

Hope this helps

Regards Stefan
No Mouse found. System halted. Press Mousebutton to continue.
musaddaq_2
Frequent Advisor

Re: How to shedule the job in crontab

Thanks to Everybody.
I have solved the problem.

Thanks again.
jayachandran.g
Regular Advisor

Re: How to shedule the job in crontab

Hi

to create a cron you just create a file (any file) and put the entries
(min)(hr) (day of the month) (month of the year) (week day) (command)

#vi try
put the entries
then you can do
#crontab try (try is you file name)

thats it

then there will be a file in /var/spool/crontabs. this file will be the name of the user who made that cron.

example if the user "osomabinladen" created a cron job then /var/spool/crontabs/osomabinladen file will be there. :)
Eric Antunes
Honored Contributor

Re: How to shedule the job in crontab

Hi Musaddaq,

Go to /usr/spool/cron/crontabs and do (as the user you want to execute this job):

$vi .tmp

In the file add:

00 22 * * * $HOME/scripts/.sh

Save you work and quit. Verify the file as the apropriate permissions (at least read and write for the owner) and schedule it:

$crontab .tmp

Best Regards,

Eric Antunes

Each and every day is a good day to learn.
Venkatesan_5
Frequent Advisor

Re: How to shedule the job in crontab

hi,

Please go thru the steps ...

1. create a script file which you require to execute...
2. goto # cd /var/spool/cron/crontabs
3. edit root file # vi root
4. in this file put these entries
00 22 * * * /path of the script file
5. save and leave it , now it works fine...

here is the crontab help...
----- xxxx ----
the format to put in /var/spool/cron/crontabs/root file :
minute hour monthday month weekday command

-----xxxx -----
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


files :
/var/adm/cron Main cron directory
/var/adm/cron/cron.allow List of allowed users
/var/adm/cron/cron.deny List of denied users
/var/adm/cron/log Accounting information
/var/spool/cron/crontabs Directory containing the crontab files

Hope this helps you.....


regds

Venkatesan.
Manoj_36
Advisor

Re: How to shedule the job in crontab

Hi,
Only root user can use the crontab command, but to give pemission to users to use the crontab command for scheduling the jobs there should be the entery of the users in /var/adm/cron/cron.allow file. So first of all make sure that you are root or a regular user, if you are root then ok otherwise put the name of that user in /var/adm/cron/cron.allow.
Now to use the cron just give a command 'crontab -e' it will open you a temporary file in vi editor there you make you cron entry and save the file. As you save the file cron saves this temporary file in /var/spool/cron/crontabs directory by the username who is giving 'crontab -e' command.
If you are root then you will get this file as /var/spool/cron/crontabs/root. If you are a regular user lets take it as user1 then this file be as /var/spool/cron/crontabs/user1.
So this is how you can cron a job.
And to see your cron scheduled jobs just give 'crontab -l' command it will show you your scheduled jobs.

Regards,
Manoj