Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
["solved"]vixie-cron not working with output redirection
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
noclear2000
Apprentice
Apprentice


Joined: 21 Jun 2006
Posts: 153
Location: Germany

PostPosted: Fri Aug 23, 2013 1:45 pm    Post subject: ["solved"]vixie-cron not working with output redir Reply with quote

Hi there,

I am using vixie-cron on my Gentoo installation and I am running lots of jobs with it. Normally I do not want to receive mail about its stdout but only stderr (to be informed about problems).

When I schedule a script I get its output (stdout and stderr) via mail each time it gets executed. So that's just fine:
Code:

0 * * * * /home/thilo/scripts/backup_snapper/make_snapshot.sh


When I try to supress stdout output like this:
Code:

0 * * * * /home/thilo/scripts/backup_snapper/make_snapshot.sh > /dev/null


The script doesn't get executed.

Any idea why?

Cheers,


Last edited by noclear2000 on Fri Aug 30, 2013 12:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1480

PostPosted: Fri Aug 23, 2013 2:07 pm    Post subject: Reply with quote

These look alike crontab entries. This is not a script but a sort of timetable, where you cannot redirect. Consult your vixie-cron docs for loglevel etc ...
Back to top
View user's profile Send private message
noclear2000
Apprentice
Apprentice


Joined: 21 Jun 2006
Posts: 153
Location: Germany

PostPosted: Sun Aug 25, 2013 9:28 am    Post subject: Reply with quote

H ulenrich,

Thanks for your reply. Yes, that is a timetable. That's what the crontab is, right?
Code:

root@treehouse [~]# crontab -l | grep make
#0 * * * * /home/thilo/scripts/backup_snapper/make_snapshot.sh > /dev/null
0 * * * * /home/thilo/scripts/backup_snapper/make_snapshot.sh

The commented line wouldn't work. The other works.

Redirecting output in crontab is a pretty basic/standard task, right? I've seen those things daily at work... Why shouldn't it work?

Or do you intend to say rtf vixie-cron m? Is there something written like "unless other cron implementations vixie-cron doesn't support output redirection in crontab"? I will read the docs to find out. :)

If this is misinterpreting your reply, please help me to undertsand it. Thanks a lot!

Cheers
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1480

PostPosted: Sun Aug 25, 2013 11:45 am    Post subject: Reply with quote

Despite there is an example in usr/share/doc showing redirection of cron entries,
but this example is 20 years old.

The entries of vixie-cron are run by this bash script
/usr/sbin/run-crons
Code:
...
    find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \; &>/dev/null || true
...

which shows there is already a redirection to /dev/null.
Probably it isn't possible to re- redirect /dev/null to /dev/null

Solution is to edit one line in /etc/crontab
Code:
*/10  *  * * *  root    test -x  /usr/local/bin/MYruncrons && /usr/local/bin/MYruncrons

cp /usr/sbin/run-crons /usr/local/bin/MYruncrons
vim /usr/local/bin/MYruncrons
... and play with your redirections as you like it!
Back to top
View user's profile Send private message
noclear2000
Apprentice
Apprentice


Joined: 21 Jun 2006
Posts: 153
Location: Germany

PostPosted: Fri Aug 30, 2013 12:35 pm    Post subject: Reply with quote

Hi and thanks again for your help.

What I did now is that I did put it all in wrapper script which I scheduled with no redirection. The redirection is done in the wrapper scripts. That works as desired.

Cheers
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum