The tag has no wiki summary.

learn more… | top users | synonyms

26
votes
2answers
30k 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
539 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 ...
15
votes
4answers
35k views

How to stop a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to stop its process, then start it again. How can I stop it? I haven't close its shell window. ...
10
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
102 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
68 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
912 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
838 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
461 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 ...