Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have some embedded machines which are on an unreliable connection which network manager unfortunately isn't handling well. Currently I need to check for connectivity and then restart network manager if we're not connected, as that will in most cases handle the specific situation we're seeing them fail in. I have the following script, which works fine when I run it by hand:

#!/bin/bash

host=http://google.com
timeout=60

if ! wget -S --spider --timeout=$timeout $host &>/dev/null; then
    restart network-manager
fi

I currently have an entry in /etc/cron.d/ that has */15 * * * * root /usr/bin/check_connectivity. I can see that the script is being run by reading the cron logs, but when I watch the network manager logs, I can see that even when I test with no connections active, it does not restart the connection. Running the script by hand succeeds and NM is restarted. There are no error messages in cron's logs and even when I remove the output dumping, I still get nothing back. I'm at a loss for why it's failing. I might think that it isn't able to talk to dbus properly, but if that were the case I'd see some error output.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Check root's e-mail. Cron sends all output in a mail message to the owner of the crontab. My guess is that "restart" isn't in cron's path. I always include a "PATH=" line near the top of my scripts for this and other reasons.

share|improve this answer
    
Where can I check this? The box isn't configured to send email anywhere. Regardless I'll check the PATH –  Daenyth Jul 8 '10 at 19:11
1  
If you use files in cron.d a then you're going to have to put an absolute path on everything because no environment variables will be attached. –  Satanicpuppy Jul 8 '10 at 19:15
    
To check root's mail, try just running "mailx" or "mail" or "pine" as root. –  nerdatmath Jul 8 '10 at 19:28
    
The path was the issue, thanks! –  Daenyth Jul 8 '10 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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