How to View multiple Cron jobs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to View multiple Cron jobs
# 8  
Old 07-31-2011
Quote:
Originally Posted by walforum
Here is the question again:

Why does crontab -l command always show only the "latest scheduled" cron job, I wish to display all cronjobs that have been scheduled not just the latest one. How do you do this?
If you are using crontab -e and entering one job, then saving the file, and then invoking crontab again to enter the "next" job you will have problems.

The crontab file is a list of all scheduled jobs. When you edit it using crontab -e you need to add all of your jobs in the edit session, not just one. So your file will look something like this to run two jobs at the desired time (just past midnight and 8am in this example):

Code:
1 0 * * * /home/scooter/bin/cleanup >/tmp/logs/cleanup 2>&1
0 8 * * *  /home/scooter/bin/daily_run >/tmp/logs/daily 2>&1

When you edit the file again, you will see all of the jobs and you can either add to them, modify them, or delete one or more jobs. Then save the file.

Make sure that you have no blank lines in the file. You might want to read the manual page for both crontab(1) and crontab(5).
This User Gave Thanks to agama For This Post:
# 9  
Old 07-31-2011
Quote:
Originally Posted by agama
If you are using crontab -e and entering one job, then saving the file, and then invoking crontab again to enter the "next" job you will have problems.
Why would that be a problem? As long as the file is saved...

@OP: That may be your problem -- are you saving the crontab after editing? What editor are you using? Have you tried the suggestion posted above with setting the EDITOR var?
# 10  
Old 07-31-2011
Quote:
Originally Posted by mirni
Why would that be a problem? As long as the file is [I]saved...
I assumed that the OP was saving just one line at a time and not all jobs. Might not be, but that's the only way I could think to explain why crontab -l wasn't listing all jobs.
# 11  
Old 07-31-2011
Thanks Guys
The post by agama has been very helpful !!!
I put all the cron jobs in one file and after saving it displayed:

crontab: installing new crontab

editng with crontab -e is also helpful as opposed to editing with vi or other editors
Problem Solved!
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to run multiple cron jobs?

I have two scripts which I'm tying to run one after the other- this is what I've tried: 00 14 * * * /path/one.sh && /path/two.sh I've also tried putting each script on a different line: 00 14 * * * /path/one.sh 00 14 * * * /path/two.sh Can this be done? (1 Reply)
Discussion started by: $shell_Learner
1 Replies

2. Shell Programming and Scripting

How to view the cron jobs that ran on kinit i keep getting must be privileged to use -u?

How to view the cron jobs that ran on kinit i keep getting must be privileged to use -u this is the control used, echo 'cat /usr/local/bin/tpthadoop/secret/hadoop.txt' | kinit hdfs what happens with above command kinit is using kerberos and the account used to run the processes jobs are... (1 Reply)
Discussion started by: cplusplus1
1 Replies

3. Shell Programming and Scripting

Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job. Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE. I need an help how to start. Attaching the JOB dependency... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

4. Solaris

Cron jobs and at jobs

There are two jobs in Solaris , Cron and at jobs.. I know how to disable or enable cron jobs. How can I enable at jobs and disable it. Kindly help. Rj (2 Replies)
Discussion started by: jegaraman
2 Replies

5. UNIX for Dummies Questions & Answers

cron jobs

Hi, We have a group of hosts using which the cron jobs are submitted... Few days ago i had submitted a cron job in of these hosts, but unfortunately forgot the host name :( Can anyone please help me out in finding this host name from which the cron s submitting the job, i dont want the... (2 Replies)
Discussion started by: bhavanisree
2 Replies

6. UNIX for Advanced & Expert Users

cron jobs...

I need to start a job every friday night at 8:00 P.M , it runs all the day on Sat and Sun....can somebody tell me how to do this...I understand crontab...but haven't used it.........can u write some steps.....how to create a file and call.....I honestly dont know? Plz help.Thanks (2 Replies)
Discussion started by: RubinPat
2 Replies

7. UNIX for Dummies Questions & Answers

Re : Set multiple cron jobs in one crontab file

Hello All, Hopw all is fine. I am newbie to Unix. I am using Bourne Shell (sh). One of the question I have is that I am trying to read XML file and based on reading that XML file I want to run different java programs at different hours. Meaning 05 14 * * * java ./program1 10 14 * * * java... (3 Replies)
Discussion started by: samshaw
3 Replies

8. AIX

comment jobs in cron for multiple accounts

Hi, We have several jobs scheduled in cron in AIX. Before every release we need to comment those jobs and uncomment those after the release is over. There are several accounts whose cron entries need to be commented. Can anyone provide me with a script which can put a '#' before each line in... (3 Replies)
Discussion started by: shibajighosh
3 Replies

9. HP-UX

Cron jobs

i am new for cronjobs can someone please tell me what logic is behind these RED Numbers and stars below? --> crontab -l 00 1 * * * /home/scripts/TarprodContent > /tmp/MprodBkup.log 2>&1 00 1 * * * /home/scripts/TarTprodContent > /tmp/TprodBkup.log 2>&1 00 1 * * *... (5 Replies)
Discussion started by: ajadaun
5 Replies

10. UNIX for Advanced & Expert Users

cron jobs

I need to monitor my cron jobs with another unix machine since occasionally the cron will go down on the main server but there are no errors. Can anyone help with a script to write to use the cron on the back up machine to monitor the main server? I am using SCO and the cron jobs have been... (3 Replies)
Discussion started by: rmarral
3 Replies
Login or Register to Ask a Question