I have one simple .sh script:
#!/bin/bash
echo "Test1"
touch /home/john/test.txt
echo "Test2"
It is executable and available (ugo+x). If I run this script, it works like I expected.
But if I try to run it in crontab, then I don't get any results. I can see in log, that job starts and I get (No MTA installed, discarding output).
AFAIK - this message isn't error? It just means that I don't have a mail (or other output channel)? But why there is no results from script? BTW - in CRONTAB I use next line:
30 * * * * sh file.sh >> /home/john/log.log
Any idea?
If your script is executable, then you don't need to have your crontab running
/bin/sh file.sh
.Also,
file.sh
probably isn't in the directory crontab runs on. You'll prefer using/path/to/file.sh
Redirecting your crontab output, you'll want to catch stderr as well. Having caught both stdout & stderr, I seem to recall crontab no longer complains about its ability to relay output.
Thank you all, with your suggestions I have found mistake. I didn't use full paths in crontab and this was the reason.