Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I have three problem, all of them are about crontab.

  1. Can I access $HOME variable in crontab ? for example, use $HOME like this: PATH=$HOME/bin:$HOME/scripts:$PATH ? or * * * * * echo "test" > $HOME/test.txt ?

  2. I want let crontab redirect normal stdout to /dev/null, but mail stderr to user. For example, when computer is not connected to network, then an entry in crontab like * 2 * * * getmail -n -q ... will return error, so crontab will send email to user with this error.

  3. based on upper example, getmail will let crontab mail user when system is not connected to network, so I want a method to detect whether user is connected to network.

About this method of detecting, it should has bellowing:

  1. fast

  2. simple

  3. easy to combine with other crontab jobs, (like use control: &&, ||, | etc)

share|improve this question
  1. sure
  2. * 2 * * * getmail -n -q ... > /dev/null

if you want redirect both stdout and stderr, then ... 2>&1 > /dev/null

share|improve this answer
2. I found a more simple one, &>/dev/null. – stardiviner Jun 22 '12 at 9:06
found in Google? had to do it before the stupid questions asked – cadmi Jun 22 '12 at 13:14

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.