Crontab Question


log in

Advanced search

Questions and Answers : Unix/Linux : Crontab Question

Author Message
Profile Joe Giampaoli
Send message
Joined: 14 Sep 99
Posts: 2
Credit: 3,416
RAC: 7
Mexico
Message 6842 - Posted: 12 Jul 2004, 7:49:09 UTC
Last modified: 12 Jul 2004, 7:51:29 UTC

I created a crontab for boinc to run up at start up
such as:
* * * * * cd/boinc_dir; ./boinc_app
and it runs perfectly fine, butI have a question, is the
> /dev/null 2> /dev/null
necessary?, and what is it for?
Sorry if this question sounds dumb but I've been running LINUX for 2 weeks now. Still a newbie.
Thanks.
Joe Giampaoli

TrevMeister
Send message
Joined: 14 May 99
Posts: 3
Credit: 313,150
RAC: 0
United States
Message 6860 - Posted: 12 Jul 2004, 9:24:19 UTC

The first part, "> /dev/null", diverts "standard output" (a program's normal output) to the bit bucket (throws it out). The second part, "2> /dev/null", redirects "standard error" (a program's error messages) to the same.

Without these options, every line of output generated by Boinc--and there is a quite a bit of output--would trigger an e-mail to root.

If you wanted to be notified of errors, you could eliminate the "2> /dev/null" directive.

Profile Joe Giampaoli
Send message
Joined: 14 Sep 99
Posts: 2
Credit: 3,416
RAC: 7
Mexico
Message 7236 - Posted: 13 Jul 2004, 2:29:21 UTC - in response to Message 6860.

Ok, thanks a lot for your help.
Just to make sure the crontab line would be something like this?:

* * * * * cd/my_boinc_dir; ./my_boinc_app > /dev/null 2> /dev/null

Just want to make sure I'm not missing anything like a space or something else.

Thanks again for your help.
Joe Giampaoli

Profile Tony Salcedo
Send message
Joined: 3 Apr 99
Posts: 2
Credit: 186
RAC: 0
United States
Message 7519 - Posted: 14 Jul 2004, 3:31:06 UTC - in response to Message 7236.

If I understand the crontab format correctly, the line below will try
to run 'my_boinc_app' once a minute, every minute, all day long!!

> Ok, thanks a lot for your help.
> Just to make sure the crontab line would be something like this?:
>
> * * * * * cd/my_boinc_dir; ./my_boinc_app > /dev/null 2> /dev/null

This line is a little better behaved:

0,15,30,45 * * * * cd /my_boinc_dir/; if ps -aux | grep -v grep | grep "boinc"; then exit; else ./my_boinc_app > /dev/null 2> /dev/null; fi

It will check every 15 minutes to see if there is an active process with the string 'boinc' in it's name. If there is none, it will start 'my_boinc_app".

(you may be able to simplify the begining part from '0,15,30,45' to '*/15')

Questions and Answers : Unix/Linux : Crontab Question

Copyright © 2014 University of California