I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA. I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
On Wed, Jul 21, 2021, at 11:29 AM, John W. Himpel wrote:
I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA. I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
That sounds like a classic usage case for a cron job. One script the does the two tasks one after the other.
Why make it more complicated than that?
On Wed, 2021-07-21 at 11:46 -0700, Doug H. wrote:
On Wed, Jul 21, 2021, at 11:29 AM, John W. Himpel wrote:
I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA. I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
That sounds like a classic usage case for a cron job. One script the does the two tasks one after the other.
Why make it more complicated than that?
-- Doug Herr fedoraproject.org@wombatz.com _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Cron and anacron do not handle well the circumstances where the server is down during the time, the cron/anacron job is supposed to start. Systemd will run the job when the system is brought back up. Running the job late is acceptable. Not running the job is not acceptable.
John
On Wed, 21 Jul 2021 13:29:00 -0500 "John W. Himpel" john@jlhimpel.net wrote:
I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA. I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
Why do you need systemd for this? What is wrong with cron? Are you grow up on MS windows? Should we forget everything about unix? MS unix is the way to go? Maybe is time to switch to FreeBSD.
On Wed, Jul 21, 2021 at 08:46:32PM +0200, Bob Marcan wrote:
Why do you need systemd for this? What is wrong with cron?
Systemd timers can launch tasks with a lot more options than Cron has. Dependencies and explicit ordering of tasks is actually one of the big reasons systemd was created. Cron works fine for a lot of things, and perhaps even for the task asked in the original email, but systemd timers can do it just fine, plus you get all the extra bells and whistles, such as resource management and output to the journal.
Are you grow up on MS windows? Should we forget everything about unix? MS unix is the way to go? Maybe is time to switch to FreeBSD.
Please stop spreading FUD like this. There are other distros that don't use systemd that would gladly have you.
On Wed, Jul 21, 2021 at 01:29:00PM -0500, John W. Himpel wrote:
I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA. I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
You would want to set TASKB to be a systemd service unit that has both After and BindsTo TASKA ( See the BindsTo documentation here: https://www.freedesktop.org/software/systemd/man/systemd.unit.html#BindsTo= ).
You could even run this as a User service if it needs to run in the context of the user (instead of system).
On Wednesday, July 21, 2021 2:29:00 PM EDT John W. Himpel wrote:
I would like to run a task (TASKA) that updates some files at a specified time each day. I already can do that successfully using systemd timers and services. Upon completion of TASKA, I want to run TASKB with is an rsync command to propagate any file changes made in TASK A to other hosts. TASKA may run quickly or slowly, so I don't want to use a timer for TASKB, rather I want TASKB to execute upon the completion of TASKA.
I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA.
Suggestions are welcome.
Probably the easiest way is to specify Type=oneshot and supply two ExecStart= directives. The second will be executed *after* the first one exits *successfully*.
This is analogous to
... /usr/bin/taska && /usr/bin/taskb
inside a crontab entry.
On 7/21/21 12:29 PM, John W. Himpel wrote:
I can't seem to find the proper set of systemd options to set in the service file for TASKB to cause it to run upon completion of TASKA. Suggestions are welcome.
Why not create a shell script that runs the two tasks in sequence and run it through cron? That's what it's intended for, you know.