Sample Header Ad - 728x90

How do I pass a command group to systemd-run?

0 votes
1 answer
224 views
Why can't I pass a command group to systemd-run like this?
$ systemd-run --on-active=1 { cp file1 file2 && echo hi; }
Failed to find executable {: No such file or directory
I tried various combinations of quoting, braces, and subshells but to no avail. I feel like this might be a problem with the shell-linux divide. I looked into https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines but couldn't find a solution there either. I could of course put the commands into a script, but I really want to know what I am missing here. Any ideas? --- Context, because maybe there is a different solution entirely: I am trying to create a solution to reset network settings after a certain countdown by copying back a previously created backup file, unless another command deletes it first (when the new network settings are successful). I am attempting a solution with a transient timer with systemd-run that executes two commands, where the restart is only executed when cp succeeds: systemd-run --on-active=300 { cp /etc/systemd/network/10-wired.network.backup /etc/systemd/network/10-wired.network && systemctl restart systemd-networkd; }
Asked by ckattmann (3 rep)
Mar 1, 2023, 11:22 AM
Last activity: Mar 1, 2023, 11:50 AM