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

Can you explain with example so that we can help you to suit your requirement?

Sorry I should have described the problem a bit more. :o

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.

To do the first job then,

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,

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.

Hi Muthu,

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

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

Regards

Raj

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