Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

This evening I have been playing with cron for the first time, and have started experiencing strange results. The script that I am trying to run is a watchdog that allows me to manage a couple other scripts with a web interface. When I run the watchdog script from a shell, sudo ./ it works fine every time, and starts the scripts it is supposed to. When I add it to crotab, sudo crontab -e with the line */1 * * * * /home/user/, it does not start them, or they crash shortly after starting. These scripts do need to run as root, so I have also tried */1 * * * * sudo /home/user/, but nothing changed.

My question is 2 part.

1: How do I troubleshoot this?

2: What causes this, and why?

share|improve this question

marked as duplicate by Iain, Falcon Momot, TheCleaner, MadHatter, MDMarra Jul 28 '13 at 17:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 2 down vote accepted

1: How do I troubleshoot this?

Start by recording stderr and stdout of your script to a file (although by default cron should be mailing you the output). You can do something like:

*/1 * * * * sudo /home/user/ > /tmp/watchdog.log 2>&1

This will put any output generated by your script in /tmp/watchdog.log.

FYI: Note that */1 is identical to just * by itself.

2: What causes this, and why?

If the requiretty flag is set in /etc/sudoers, then sudo will only operate from a real TTY (e.g., from an interactive login session). That's not necessarily what's happening here but it's something to check. Look for a line along the lines of:

Defaults requiretty

in /etc/sudoers.

share|improve this answer
Thanks for the quick response! That got me going again. There was one relative file path I had missed at the very beginning of the project. – Butters Jul 28 '13 at 2:44

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