You are not logged in.

#1 2013-08-20 17:10:10

stuvjordan
Member
Registered: 2011-08-09
Posts: 26

cron and sponge

So, I'm setting up a cron job to back up data on my system.  This job could occassionally take a long time, so following the advice on archwiki, I want to use sponge or chronic to manage the emailing of the results.

For various reasons, I want to receive both stdout and stderr, so chronic is not the right solution for me.  But I haven't been able to find examples on the web of how to use sponge with cron.  So I want to make sure what I'm doing will work.  Since sponge just acts like a pipe (i.e. it reads from stdin and writes to stdout), it seems to me that it won't work to prefix the chron command in the crontab  with sponge, as one would do with chronic.  So, I'm guessing that the right way to do it is to use the -m option in the call to crond in /usr/lib/systemd/system/cronie.service, like so:

ExecStart=/usr/bin/crond -n -m '/usr/bin/sponge | /usr/bin/msmtp -t'

My question:  will that do what I intend?

Thanks!

Offline

#2 2013-08-20 19:57:38

Morrad
Member
From: Washington State, USA
Registered: 2012-01-18
Posts: 54
Website

Re: cron and sponge

stuvjordan wrote:

So, I'm guessing that the right way to do it is to use the -m option in the call to crond in /usr/lib/systemd/system/cronie.service, like so:

ExecStart=/usr/bin/crond -n -m '/usr/bin/sponge | /usr/bin/msmtp -t'

I can't help you with sponge, but note that you probably don't want to change the service file provided by the cronie package, since pacman will overwrite your changes when it updates.  You should copy it to /etc/systemd/system/cronie.service and modify that one.  It will override the package provided version (note you will also need to do 'systemctl --system daemon-reload' then 'systemctl reenable cronie.service').

Last edited by Morrad (2013-08-20 19:58:32)


To the optimist, the glass is half full.
To the pessimist, the glass if half empty.
To the engineer, the glass is twice as big as it needs to be.

Offline

#3 2013-08-21 13:06:05

stuvjordan
Member
Registered: 2011-08-09
Posts: 26

Re: cron and sponge

thanks!

Offline

Board footer

Powered by FluxBB