LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   crontab help (https://www.linuxquestions.org/questions/linux-general-1/crontab-help-79093/)

usman 08-05-2003 02:26 AM

crontab help
 
i want to add a job that i want to run daily at a specific time .. how do i accomplish this ?

shaheen 08-05-2003 02:43 AM

CROTAB HELP
 
Hi there ,
i assume you have the script ready thats going to accomplish your job. About writing the crontab here is how you do it.

First make sure which user is going to run the cron. login with that users name and password and issue a crontab -l commans .. but since there is no cron running you wont get any crontab listing. For writing the cron issue a crontab -e command. This will open up a editor window very similar to the vi editor environment. I assume you are at ease working with the vi. About crontab -r .... be careful it doesnt issue a warning !!

Every crontab entry is of the following form. There are 5 fields that you need to fill in for running the script. They are ::

(Minutes) (Hours) (Day_Of_Month) (Month) (Day_Of_Week)
These take the form (0-59) (0-23) (1-31) (1-12) (0-6) respectively , thats reasonable as you can set the minute range between 0-59.

For writing the cron :: Issue that crontab -e and u r ready to write.Remember there should always ba space between two fields.

some general examples

0 1 * * 1-5 Path_To_Your_Script/scriptname This will run every Monday-Friday at 1 A.M
0 1 * * 1,3,5 Path_To_Your_Script/scriptname This will run every Monday,Wednesday and Friday at 1 a.m
10 2 1 * * Path_To_Your_Script/scriptname This will run at 2:10 a.m on the first of every month
0 1 1 1 * Path_To_Your_Script/scriptname This will run at 1 a.m on January 1 every year
0/15 * * * * Path_To_Your_Script/scriptname This will run evry 15 minutes every day, every month, evry week , every year

I hope this will help ... do tell me if it works .. All the Best
Shaheen

usman 08-05-2003 11:02 AM

thanks shaheen it worked ..
but there is one little problem .. this is wrtten in my \etc\crontab file in the beginning
mailto = user

now wht it does is it mails the result to the user ...like forexample i was running a ls command in the script and it mailed all the list to the user . i want the list to be shown on the terminal when the script runs ..

Blinker_Fluid 08-05-2003 11:48 AM

Quote:

Originally posted by usman
thanks shaheen it worked ..
but there is one little problem .. this is wrtten in my \etc\crontab file in the beginning
mailto = user

now wht it does is it mails the result to the user ...like forexample i was running a ls command in the script and it mailed all the list to the user . i want the list to be shown on the terminal when the script runs ..

If you want something outputed to console windows then you probably want to use wall. cron will not put anything on the console by default kind of like when you do a ls in one window it doesn't put it in every window. (unless you do a ls | wall ) ;)

usman 08-05-2003 11:59 AM

oh .. o k . i get it .. thanks for the help .. :) i thought that when the cronjob runs its suppose to show wht going on the screen .. or show my some message that the job has been performed automatically ..
wht do i have to do to get notified when a certain job runs ?

ccool 08-05-2003 12:15 PM

I usually get 2 types of messages from crontab. It's either via mail or via a log file...

I think both are great solution

shaheen 08-05-2003 11:50 PM

about editing a cron job
 
hi,
about that mailto user problem , u can change the mailto=user to mailto=root , the mail will be delivered to you , not individual users , or if you dont want to use that just hash it out , wont be a problem anymore , cron doesnot display any messages in the screen , it just performs the job it has been assigned to , its the script that will print out the output , like an ls command .... so try editing the script ..

All the best .. take care .
Shaheen

usman 08-06-2003 03:37 AM

thanks again for the help .. crontab is working fine for me now :)


All times are GMT -5. The time now is 04:10 AM.