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; }