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.


ifconfig > /home/myname/foo


* * * * * /home/myname/bin/script

...waits 1 minute...

@@ 11:35:51 [myname@comp - ~]$ ls foo
-rw-r--r-- 1 myname myname 0 Jul  7 11:35 foo
@@ 11:35:55 [myname@comp - ~]$

I can't figure out why foo would end up empty. Running the ipconfig command on the command line works exactly as you'd expect, dumping its output into a file just like normal. For reference, I'm running Ubuntu 8.04.

share|improve this question
add comment

4 Answers 4

up vote 6 down vote accepted

try using the full path to the ifconfig executable in your script.

whereis ifconfig will give you the path.

I don't know what ipconfig does in ubuntu. :)

share|improve this answer
Sorry, it's ifconfig in the script, I typo'd it in the question. –  dirtside Jul 7 '09 at 18:52
I figured. I do that from time to time too. Cron usually just wants the full path so let us know how things turn out. –  egorgry Jul 7 '09 at 18:55
...but yes, it was a path problem. ifconfig is under /sbin, which is not in the default bash path. Thanks. –  dirtside Jul 7 '09 at 18:57
ah makes sense, see I always overlook something when writing scripts, nice spot egorgry –  Rodent43 Jul 7 '09 at 18:59
add comment

In a cron job you probably want to redirect both stdout and stderr to the file. Change your script to this:

ifconfig &> /home/myname/foo

and you'll see the error message in your output file.

See All About Redirection in the Bash Programming How To for more info.

share|improve this answer
add comment
  1. You probably need the full path to ipconfig in your script, or did you mean ifconfig? Either way, you should use the full path.
  2. You capture stdout in /home/myname/foo, but not stderr which probably gets the clue that you're missing here. Check your email for the output of the cronjob.
share|improve this answer
add comment

have you tried manually running your script?

cd in to /home/myname/bin/


does it make the foo with contents as expected?

is the script executable?

I know that might sound like simple things but sometimes that is what is overlooked, especially when I make a script

share|improve this answer
Yes, and yes. The script executes normally when run by hand, and it is executable. –  dirtside Jul 7 '09 at 18:52
add comment

Your Answer


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.