Score:0

Run two scripts one after another with a systemd service

us flag

I have two scripts, what I would like to do is:

  • at 1am, the first one runs
  • once the first one stops, and this is a condition, the second one fires

So, should i use:

[Service]
ExecStartPre = script.py
ExecStart = secondscript.py

or

[Service]
Type = oneshot
ExecStart = first.py
ExecStart = second.py

man notes this:

Note that ExecStartPre= may not be used to start long-running processes. All processes forked off by processes invoked via ExecStartPre= will be killed before the next service process is run.

And my scripts can be long-running ones (some hours each).

Or is there a better way to ensure second runs only after first is fully-executed?

Also, this service is called by a timer:

[Timer]
OnCalendar=*-*-* 1:00:00
Unit = script.service

and i want only one instance of this running; even if the script.service takes 3 days to run, the next run should be reported to the next day after it finishes, at 1:00:00. Is this the default?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.