How to get the process id of command executed in bash script?
问题 I have a script i want to run 2 programs at the same time, One is a c program and the other is cpulimit, I want to start the C program in the background first with "&" and then get the PID of the C program and hand it to cpulimit which will also run in the background with "&". I tried doing this below and it just starts the first program and never starts cpulimit. Also i am running this as a startup script as root using systemd in arch linux. #!/bin/bash /myprogram & PID=$! cpulimit -z -p