I have one simple .sh script:

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?

  • How did you edit crontab? crontab -e?
    – muru
    Dec 22 '16 at 5:08
  • 2
    file.sh must be in your home dir. error about MTA mean you won't receive mail from cron job.
    – Archemar
    Dec 22 '16 at 5:37

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.

30 * * * * /path/to/file.sh >> /home/john/log.log 2>&1

Thank you all, with your suggestions I have found mistake. I didn't use full paths in crontab and this was the reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.