I will run the following script:
#!/bin/bash
./myprogram
#get exit code
exitvalue=$?
#log exit code value to /var/log/messages
logger -s \"exit code of my prog
I think your better choice would be to use the date
command rather then logger
in cases where you don't want to write to the syslog files (and don't have privs to do so).
See "timestamp before an echo" for details on how to use date
to prefix a message with a date and write it to a file.
You create a bash function that looks like the following, adjusting the date
format string to get what you want:
echo_time() {
echo `date +'%b %e %R '` "$@"
}
In your bash script, you would then use:
echo_time "Your message here" >> ${LOGFILE}
Which would put the following in your ${LOGFILE}
file:
Mar 11 08:40 your message here