The tag has no wiki summary.

learn more… | top users | synonyms

23
votes
2answers
28k views

How to get the pid of the last executed command in shell script?

I want to have a shell script like this: my-app & echo $my-app-pid But I do not know how the get the pid of the just executed command. I know I can just use the jobs -p my-app command to grep ...
9
votes
3answers
439 views

If you ^Z from a process, it gets “stopped”. How do you switch back in?

I accidentally "stopped" my telnet process. Now I can neither "switch back" into it, nor can I kill it (it won't respond to kill 92929, where 92929 is the processid.) So, my question is, if you have ...
9
votes
4answers
4k views

Remove all `at` jobs

I know that to remove a scheduled at job I have to use atrm "numjob1 numjob2", but is there an easy way to do that for all the jobs?
4
votes
3answers
94 views

How do I gracefully suspend and resume `cmd1 && cmd2 && cmd3` chain?

From the previous question it seems I failed to understand how && and ^Z interact properly: $ command1 && command2 && command3 Running command1 ... Running command2 ...^Z [1]+ ...
4
votes
2answers
67 views

How do I cancel/replace one element of running `cmd1 && cmd2 && cmd3 && …` chain?

$ command1 && command2 && command3 Running command1 ... Running command2 ...^Z [1]+ Stopped $ fg && command4 && wrong_command5 && command6 Running command3 ...
1
vote
2answers
880 views

How can I queue processes?

I have a surveillance camera and a program records videos when motion is detected. Basically, this program saves the video in a very heavy format. My solution was to call a script that converts the ...
7
votes
2answers
834 views

In Bash scripting, what's the meaning of “ $! ”?

If I'm assigning a variable with temp=$! what would it be its value?
2
votes
1answer
447 views

Is it possible to customise the prompt to show the if there are any background jobs?

Is it possible to customise the bash prompt to show the if there are any background jobs? I find it easy to forget that there are background jobs. Say if the prompt was... $ Is there a way to ...