Skip to main content
added 3 characters in body
Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 138

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait -n command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait -n command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

added 62 characters in body
Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 138

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-runman systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.

Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 138

You might be open to using a systemd transient unit, as it is simple to start, control, and stop. Assuming your shell script is, say, ./myscript, add a wait command to the end of it so that is does not finish immediately, then you can start it with:

systemd-run --user --unit=mytest1 ./myscript

This command returns immediately with the message Running as unit: mytest1.service, and you can see what processes are running in the created transient unit with the usual commands:

systemctl status --user mytest1

You can stop all the processes with one command:

systemctl stop --user mytest1

To run the same script several times, just ensure you use a different --unit= name each time. If they all begin with test, then you can check on them all, or stop them all by referring to them as test*.

See man systemd-run for various options that might be useful, such as --setenv=, --working-directory=, --collect, --wait. Note that you can also pass arguments to your script at the end of the systemd-run command.