On Sun, 5 Feb 2012 13:58:36 +0100 Steve Traylen <[email protected]> wrote:
> Hi, > > I was looking migrating one fedora package, fetch-crl to systemd. It > is similar situation > also for yum-cron. > > The aim is to have a cron installed but that it only does something if > a particular service > is started. > > Currently the methods of the init.d script does > > start , touch /var/lock/subsys/fetch-crl-cron > stop , rm -f /var/lock/subsys/fetch-crl-cron > status , check if /var/lock/subsys/fetch-crl-cron exists > > and the then the cron job starts with > > if [ -f /var/lock/subsys/fetch-crl-cron ] ; then > do something > else > exit > fi > > The reason for this is for instance you don't want to run the cron job > with no network > in single user mode for instance. > > So I can replicate this to some extent with > [Service] > Type=oneshot > RemainAfterExit=yes > ExecStart=/bin/touch /var/lock/subsys/fetch-crl-cron > ExecStop=/bin/rm -f /var/lock/subsys/fetch-crl-cron > > but this is rubbish in particular status is not correct if that file > is deleted for > some reason. I could not see a way to add an ExecStatus command? > Why do you need these at all? Can't you just use "systemctl status my-network-something.service"? For example, assuming "fetch-crl" is some binary which should be running when cron-job works, just make a service that runs it and check if that service is active from job. fetch-crl.service: [Service] ExecStart=/usr/bin/fetch-crl fetch-crl cronjob: #!/bin/sh systemctl -q is-active fetch-crl.service || exit 0 ... Another "magic" you can probably use is to make oneshot fetch-crl-cron.service, with some .timer unit instead of cron, then use BindTo= for the timer or Requisite= in a fetch-crl-cron.service (which should have roughly same effect as the "systemctl is-active" line above if you start it manually). > But more over I am probably going about this all wrong? I guess I want > an "empty" > service and then have the cron job query that directly. Or there is > some other systemd > magic I am unaware of. > > Any suggestion as to what to do here. > > Steve. > > > > -- Mike Kazantsev // fraggod.net _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
