1

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)

3
  1. sure
  2. * 2 * * * getmail -n -q ... > /dev/null

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

  • 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 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.