Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer

  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. –  NagatoPain 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
add comment

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.