View previous topic :: View next topic |
Author |
Message |
noclear2000 Apprentice
Joined: 21 Jun 2006 Posts: 153 Location: Germany
|
Posted: Fri Aug 23, 2013 1:45 pm Post subject: ["solved"]vixie-cron not working with output redir |
|
|
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 |
|
|
ulenrich Veteran
Joined: 10 Oct 2010 Posts: 1480
|
Posted: Fri Aug 23, 2013 2:07 pm Post subject: |
|
|
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 |
|
|
noclear2000 Apprentice
Joined: 21 Jun 2006 Posts: 153 Location: Germany
|
Posted: Sun Aug 25, 2013 9:28 am Post subject: |
|
|
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 |
|
|
ulenrich Veteran
Joined: 10 Oct 2010 Posts: 1480
|
Posted: Sun Aug 25, 2013 11:45 am Post subject: |
|
|
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 |
|
|
noclear2000 Apprentice
Joined: 21 Jun 2006 Posts: 153 Location: Germany
|
Posted: Fri Aug 30, 2013 12:35 pm Post subject: |
|
|
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 |
|
|
|