I am currently running a cron job to schedule my shell script after a particular interval but i am not able to see my shell script execution and the log how can i see it.
You can use the redirection sign (
>) in order to redirect the
stderr to a log file.
0 0 * * * /path/to/shell-script.sh > /tmp/shell-script.log 2>&1
0 0 * * *means the script will run every day at midnight
/path/to/shell-script.sh- the path of the script
>means redirect the stream to a file followed by the redirection sign
1 is the standard output (
2 is the standard error (
Here is one way to remember this construct (although it is not entirely accurate): at first,
2>1 may look like a good way to redirect
stdout. However, it will actually be interpreted as "redirect
stderr to a file named
& indicates that what follows is a file descriptor and not a filename. So the construct becomes: