This is what I'm using as a header in all the scripts I write now. It makes it easy to adapt scripts on the fly.

Further improvements I'm going to make, when I have time:Make the script read a central configuration file that specifies which one of the following three modes it should use, so I caneasily switch all my scripts between debugging and discarding information.Possibly make it so the configuration file has an entry for each script so they can look up to see what mode they should functionunder (using the $0 parameter)

Code:

# Log all output to a file for later viewing (For Cron jobs that need monitoring)OUTPUT=/home/manu/runlog# Don't echo anything at all (For Cron jobs that have been tested sufficiently and don't need to show up in the log)# OUTPUT=/dev/null # For when I run it myself from the commandline and want to see all output.# OUTPUT=/dev/stdout

## Code with, for example:echo "Download completed" >> $OUTPUTecho "The year is $(date +%Y), and the time is $(date +%T)" >> $OUTPUT

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum