The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



Thread: crontab help
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 12-04-2005
grahamb grahamb is offline
Junior Member
 

Join Date: Dec 2005
Location: Windsor, Ont Canada
Posts: 13
Output from crontab

Hi Satish:

Your last question: how can we capture the output of the cronjob.

Use the directional parameters "> $file" and/or ">> $file" for example. Anything that goes to stdout would then be routed to $file. Any other stdoutput would, for example go into the mail of the user who has called the crontab-job.

Try something like this:
Code:
10 4 * * * . ~/.bashrc; ${SCRIPTS}/backup_mysql.sh >> ${BACKUPS_LOG}/${HOSTNAME}_mysql_v${VERS}.script.log 2>&1
My practice is to get output from the specific functions in the program to output to log files. For example the program "./backup_mysql.sh" may generate files that are of interest to specific users.

Above the redirection is to a log-file describing the overall performance of the program and the variable used by "./backup_mysql.sh". This logs data that would be of interest to the administrator, for example.

Note: "2>&1" is also a redirection. Another story!

regards
GrahamB
Reply With Quote