script to extract crontab entries


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to extract crontab entries
# 1  
Old 03-08-2005
script to extract crontab entries

Hi,

I am wondering if anyone has got a script to extract information such as frequnecy, date, time, file, log file etc. from crontab and put in a csv or similar format.

Thanks

Raj
# 2  
Old 03-08-2005
Can you explain with example so that we can help you to suit your requirement?
# 3  
Old 03-08-2005
Sorry I should have described the problem a bit more. Smilie

Here is what I want to do:
1) Get a list of jobs that are run with the tima and day information in csv (or similar) format
2) Look at the time the log files are created to estimate the duration for each job

eg read the following line

00 08 1 * * /home/test.ksh > /tmp/test.log 2>&1

to print the output
00,08,1,all,all,/home/test.ksh,/tmp/test.log

and for task (2) look at the timestamp of the log file (test.log) and subtract the start time of the job eg

-rw-r--r-- 1 oracle dba 0 Mar 8 8:10 test.log

get the duration the task ran - 10 minutes.
# 4  
Old 03-08-2005
To do the first job then,

Code:
crontab -l | awk '!/^#/ { for (i=1;i<=6;i++) { printf $i",";} printf $7"\n"}'

For second job we have to play with cron log and file creation log information as,
Code:
stime=$(grep '/home/test.ksh' /var/log/cron | awk 'END{ print $3 }')
etime=$(/tmp/test.log | awk '{ print $8":00" }')
... <code to be added to get the time difference ..

HTH.
# 5  
Old 03-08-2005
Hi Muthu,

Thanks a lot for your help. I tried the first task and it is working Smilie.

I will get the rest of the code for the second task to estimate the duration of each run.

Regards

Raj
# 6  
Old 03-09-2008
Java

hi
i am looking for the same .. start and end timestamp difference
in a log file or multiple log files in same location
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to list all crontab entries?

Hi, 1. How can I list all the crontab entries of all system users (like root, adm, sys etc.) as we have multiple files like /etc/crontab , /var/spool/cron, /etc/cron.d, /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly etc. 2. How can I list all the crontab entries of ALL users on a... (1 Reply)
Discussion started by: prvnrk
1 Replies

2. UNIX for Dummies Questions & Answers

Crontab in script

I have crontab setup via crontab -e I was wondering if its possible to create a cron job from a script so when the script is run the cron job is created? (3 Replies)
Discussion started by: scriptnewbie
3 Replies

3. UNIX for Dummies Questions & Answers

How to change crontab entries?

How to edit crontab entries . A job is scheduled as 35 15 * * * it.sh rahul_raj/hdhd i want to change it as 45 15 * * * it.sh rahul_raj/hdhd 1.crontab -e 2.shift+g ---go to last line .press enter.Press <i> . After this what should i do? (6 Replies)
Discussion started by: rafa_fed2
6 Replies

4. Shell Programming and Scripting

Make entries in crontab file

I have created a shell script "abcd.sh" and script should run after every 10 min., For that I will create below entry in the crontab file by using command crontab -e */10 * * * * /cdr/work/proc_raw/abcd.sh >> /dev/null 2>&1 I wish to know whether above entry is correct or I have to make entry... (2 Replies)
Discussion started by: Devesh5683
2 Replies

5. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when... (6 Replies)
Discussion started by: G30
6 Replies

6. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when I... (2 Replies)
Discussion started by: G30
2 Replies

7. Shell Programming and Scripting

Shell script to generate daily crontab entries between to specific dates

Hi, I am currently writing a shell script to enter daily reoccurring jobs into the crontab. I want to be able to specify any two dates for which I want these daily jobs to run between. Below is an example of what I need to be written to crontab. # Give a start day of 21/10/2009 09:00... (2 Replies)
Discussion started by: JM_86
2 Replies

8. Solaris

Duplicate crontab entries

hi guys. can someone tell me what will happen if there are two identical crontab entry for an application. For example 03 23 * * 1 /usr/vt/crondemo 03 23 * * 1 /usr/vt/crondemo will the file crondemo run twice, once or wont run at all?? (2 Replies)
Discussion started by: vikashtulsiyan
2 Replies

9. Shell Programming and Scripting

how to change crontab entries

Hi Friends, I need to change crontab entries in prod. $crontab -l -> using this i can see the entries only Plese tell me how to edit this crontab and how to change the entires Waiting for ...... Thanks In advance friends Krish. (2 Replies)
Discussion started by: kittusri9
2 Replies

10. UNIX for Advanced & Expert Users

crontab entries deleted !!

Hi all, A friend of mine accidently erased all crontab entries by typing crontab -r. Can anyone pls. help me on this. Is it possible that a backup file is available other than files from the backup tape. Or is it retrievable ??? Thnx, MK (6 Replies)
Discussion started by: minazk
6 Replies
Login or Register to Ask a Question