Crontab jobs log

hi gurus,

I have scheduled some script by using crontab. I would like to save all the logs in some particular directory whenever the jobs are running. please let me know how i need to code it to save the logs files.

Hello arun888,

You can do following just an example for a script which runs a script to take backup and re-directing it's logs to a log file too.

 */1 * * * * /home/Singh/vimbackup.sh >> /home/Singh/vimbackup.log 2>&1
 

Where explanation for 2>&1 is as follows too.

 2 refers to the second file descriptor of the process, i.e. stderr.
 > means redirection.
 &1 means the target of the redirection should be the same location as the first file descriptor, i.e. stdout.
 

Hope this helps. You can do man crontab too.

Thanks,
R. Singh

1 Like

hi ravi,

Its works . thanks a lot for your help.