I'm looking for a way to log crontable events. thus by writing in a log file the date of execution and the result. for example
Tue Feb 14 11:17:01 CET 2017 Finish with success
Tue Feb 14 11:18:01 CET 2017 Finish with errors
So for the first one i've found a way to do it. By this way:
0,5,10,15 * * * * /path/to/script $args 2>> /path/to/logFile.log && echo "$(date) Finish with success" >> /path/to/logFile.log
So when there's an error I don't know how to replace the error output by the string "$(date) Finish with errors"
Add the log on failure condition with the Boolean
||
operator which executes on failure of the command,Append
stdout
to file andstderr
toNULL
as>> /path/to/logFile.log 2>/dev/null