Questions tagged [jobs]
Job control in a shell
141
questions
1
vote
1
answer
60
views
What signal do bg and fg send?
I know that ctrl + z changes a process from foreground to background - as suspended - through SIGTSTP. I am able to re-run that background suspended process through either fg or bg as required.
...
0
votes
0
answers
20
views
jobs command: How report all the done/finished processes, but at anytime?
About background processes, for simplicity if for example are executed:
sleep 300 &
sleep 350 &
sleep 360 &
sleep 400 &
sleep 800 &
When is executed jobs -l, in the output is ...
0
votes
2
answers
46
views
How do I list all background processes?
Is it possible to list all running background processes with the ps command, or is the only option for getting a list of background processes the jobs command?
1
vote
2
answers
25
views
Call other process after executing a blocking process in shell
I have a process that is blocking in nature. It is executed first. In order to execute the second process, I moved the first process to the background and executed the second process. Using the wait ...
2
votes
2
answers
24
views
Is there a way to quickly change dir to one from where one of the jobs is running?
The output of jobs looks something like this
[1] Stopped TERM=xterm-256color vim --servername vim ~/.gitconfig
[2]- Stopped TERM=xterm-256color vim --servername vim ~...
2
votes
1
answer
198
views
Reliable way to get PID of piped background process
I need to retrieve the PID of a process piped into another process that together are spawned as a background job in bash. Previously I simply relied on pgrep, but as it turns out there can be a delay ...
0
votes
2
answers
109
views
cron job terminating after sometime while executing the script
I have several cronjobs which runs at different times in a day, but one particular cron job is not running as expected and getting terminated after sometime.
0 0 * * * python3 /scratch/pyscripts/...
2
votes
0
answers
41
views
Can't grep or word count the output of jobs command in dash
This is what I tested in Arch's dash shell and FreeBSD's default sh shell, the results are the same.
$ sleep 100 &
$ jobs
[1] + Running sleep 100
$ jobs | wc
0 0 ...
1
vote
0
answers
46
views
run one command and execute another after first killed by CTRL C in bash
I need to start a service1 in bash commandline. After a while I dont need that service anymore
and I do a CTRL-C to stop it. The service started another background service2. To stop that I usually do ...
0
votes
0
answers
202
views
start command in linux
I have a custom script which runs on a cPanel server (CentOS 6) which is as below. It starts a service on the specified port which accepts incoming data.
It uses start command and runs ok.
#!/bin/bash
...
1
vote
1
answer
125
views
"kill %{job id}" vs "kill {job pid}"
I'm working with some tail -f path/to/my/log/file | grep pattern& and I need to kill the process as quick as possible.
With classic kill {tail PID}, tail still displays its buffer and it takes ...
8
votes
3
answers
1k
views
Why sleep command process is still running in the background while I stopped it with CTRL-Z?
What I do is:
sleep 5
and immediately CTRL-Z so when I open jobs I see:
[1]+ Stopped sleep 5
next when I do fg %1 sleep process is no more running, it's done so that means it was ...
0
votes
0
answers
44
views
How to execute bindkey shortcut in same TTY?
My goal is to create a notifier function in zsh that tells me when a current command has finished running. The function is basically running and implemented but there is still one bug that I want to ...
-4
votes
1
answer
157
views
What's the difference between: application, program, process, job, task, service, daemon, script, command? [closed]
Can someone clearly provide the differences and/or equivalences between these terms? I always get something mixed up, and keep losing track whilst reading documentation...
Helpful previous answers:
...
2
votes
3
answers
3k
views
Waiting for any process to finish in bash script
I am trying to check how many active processes are running in a bash script. The idea is to keep x processes running and when one finished then the next process is started.
For testing purposes I set ...
0
votes
1
answer
88
views
Bring multiple background jobs to foreground
I’ve got 2 background jobs running, I got their job ids using jobs is it possible to bring them both to the foreground using the fg <jobId> cmd? I can’t seem to add 2 parameters.
1
vote
1
answer
458
views
What's the difference between a "job" and a "service" to systemctl?
What's the difference between a "job" and a "process" "service" wrt these two systemctl commands?
root@linuxbox:~# systemctl list-jobs
No jobs running.
root@linuxbox:~# ...
1
vote
2
answers
128
views
Can't kill stopped jobs with bash script
for i in $( seq 1 $1 )
do
kill %$i
done
I try to kill the stopped jobs with this script, but interestingly it can't be able to even though I have jobs open.
$ jobs
[10] Stopped ...
0
votes
0
answers
21
views
How verify cancelled print job in script
I need to verify that a print job has been cancelled, and to do this in a script.
But lpstat's "completed-jobs" list appears to include those that have been cancelled. So it appears I cannot ...
1
vote
0
answers
44
views
How to return a value from a job?
I want to spin up some jobs within a script to do some work in parallel. I will know when the work is done by counting the number of active jobs. The issue I'm having is that I want to also return a ...
0
votes
1
answer
23
views
How to kill jobs from a script that didn't clean them up
I have a script that started a job but didn't clean it up. The job is running in a loop in the background and I don't know which process it is and it's not listed in jobs. It's printing spam in my ...
0
votes
1
answer
112
views
Print to stdout process ids that were killed
Using the kill command, is there a way to print to stdout the process ids of the background processes being killed?
After searching via Google, there seems to be (on some Unix or Linux) a --verbose ...
1
vote
1
answer
75
views
How does one kill jobs submitted via bg in one subshell from another shell instance?
Suppose, as a dummy example, I execute a bash command in one terminal tab:
$: sleep 1000 &
Then, in another tab, I run the command that should "kill all background jobs":
$: jobs -p | ...
2
votes
1
answer
117
views
'jobs' shows a no longer existing process as running
I'm running a long-running pipeline from bash, in the background:
find / -size +500M -name '*.txt' -mtime +90 |
xargs -n1 gzip -v9 &
The 2nd stage of the pipeline takes a long time to complete ...
-1
votes
1
answer
130
views
Can I resume a job in the background and redirect its standard output to a file? [duplicate]
I have stopped a job by pressing Ctrl-z. Can I resume the job with bg, yet have the output redirected to a log file instead of stdout? Doing the following:
bg > log.txt
Only writes the initial ...
0
votes
0
answers
472
views
Understanding background processes and terminal process group id
I am reading the bash reference manual about Job control found here (emphasis mine):
To facilitate the implementation of the user interface to job control,
the operating system maintains the notion ...
0
votes
0
answers
59
views
Why bash need job control?
Why Unix systems need job control?
So for example, we can use the process number or job number(jobspec) with the kill command.
$ sleep 101 &
[1] 19
$ sleep 102 &
[2] 20
$ jobs -l
[1]- 19 ...
4
votes
1
answer
162
views
Usage example of "x" option of "jobs" command in bash
When i look at the jobs -x explanations, it says:
If the -x option is supplied, jobs replaces any jobspec found in command or arguments with the corresponding process group ID, and executes command, ...
0
votes
1
answer
144
views
Why is a process being shown while using "jobs" command after killing the process manually?
Why is the parole(just a media palyer) still listed in the "JOBS" command output even after killing maually and why is not listed in the "PS" command output ?
Does this mean the ...
1
vote
1
answer
64
views
Return to a particular job in the jobs list
If I have the following jobs running in a shell
-> % jobs -l
[1] 83664 suspended nvim
[2] 84330 suspended python
[3] 84344 suspended python
[4] 84376 suspended nvim
[5] - 84701 ...
1
vote
1
answer
789
views
zsh: Why do I get suspended background processes even when I have `stty -tostop`?
I like my background processes to freely write to the tty. stty -tostop is already the default in my zsh (I don't know why, perhaps because of OhMyzsh?):
❯ stty -a |rg tostop ...
0
votes
1
answer
74
views
cron job for ubuntu to solve apache2 ram problem
Sometimes Apache2 keeps generating new processes till the ram is totally consumed and all websites become very very slow.
I wrote a bash file and created a cron job that checks ram usage every minute. ...
0
votes
2
answers
183
views
Unable to resume execution of a background process
I tried to install git through the command line,
sudo apt install git.
I put that process into the background by pressing Ctrl-Z. This also stops the process's execution so I tried to resume with
...
0
votes
2
answers
173
views
How do you keep this dastardly bash script running in the background 24/7?
This might sound like a duplicate, but hear me out first.
I run a shell script, which has a standard input active and sometimes on startup requires some input. I need for it to run 24/7 and it needs ...
1
vote
1
answer
111
views
How does bash `auto_resume` job control variable works?
Chapter 7.3 Job Control Variables in Bash Reference Manual has the following description about auto_resume variable:
auto_resume
This variable controls how the shell interacts with the user ...
1
vote
0
answers
54
views
Why `kill %jobnumber` not working on stopped jobs? [duplicate]
I'm running few tasks side by side on an ubuntu 18 LTS. So I'm switching between these jobs by running
# command &
# fg
# fg -
(Also) use of Ctrl+z sometimes to send running job to background.
...
0
votes
1
answer
35
views
How do I change a value in a line of an existing script to reflect the (numerical) folder name?
I'm running a job where I have multiple folders (labelled 0 to 41), each containing an identical script which need the ninth line edited:
#SBATCH -J aXau19
X should correspond to the name of the ...
0
votes
1
answer
194
views
How much storage is this fio command utilizing?
I have a fio workload running as a Job.
Fio workload:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: fio-target
spec:
#storageClassName: ocs-storagecluster-cephfs
...
1
vote
1
answer
492
views
How to kill all background jobs in dash?
Simply kill $( jobs -p ) not work in dash.
For example in dash:
$ sleep 999 &
$ kill $(jobs -p)
dash: 2: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [...
0
votes
2
answers
490
views
Get output redirection part of a running process
Sometimes I run jobs, I lose track of which output files I have redirected the output to. How can I get the full command I ran a job with, including the output redirection part?
For example, when I ...
1
vote
0
answers
195
views
Key binding to swap shell foreground/background jobs
In spite of heavy tmux use and switching between panes, I still frequently find myself using shell job control. When something needs poking I'll background the tool I'm using with Ctrl+Z, poke the ...
0
votes
0
answers
338
views
How to kill a process from Cron
Usually I do like this:
kill -9 $(ps aux|grep Firefox|awk '{print($2)}')
But when I try following via cron, it does nothing.
50 * * * * kill -9 $(ps aux|grep Firefox|awk '{print($2)}')
Mind you the ...
0
votes
1
answer
220
views
jobname or alias for background job
Is there any way to put names or aliases for identification in jobs?
I tried a clumsy
> sleep 10 & # this job sleeps 10 seconds
but jobs returns
[1] + running sleep 10
And I couldn't ...
1
vote
1
answer
889
views
Editing a job in At command
Trying here to modify a job from at command.
Any idea on how to do it?
Already managed to list it, delete, and execute, but can't modify it.
0
votes
0
answers
89
views
show stdout of background jobs inline
Is there an easy way to make the jobs command display its stdout inline?
I am backgrounding long-running jobs with integer outputs. I need to visually compare those outputs, but they are sent without ...
1
vote
1
answer
1k
views
Opening interactive python shell after running python script in background
python3 -i test.py opens an interactive python shell after running test.py. However, if I try to run it in the background with python3 -i test.py &
the job stops automatically with a ^C and shows
...
3
votes
0
answers
851
views
Bash: kill process and all subprocesses without using group id
TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code.
I have a ...
9
votes
1
answer
708
views
Explain why watch 'jobs' does not work but watch 'ps' work?
jobs is my favorite command to see my codes which are running in the background. In order to check for them dynamically, I tend to type
watch 'jobs'
which does not display anything. However
watch '...
1
vote
1
answer
991
views
A stop job is running... if I execute dhcpcd and don't kill it on ARCH
I have recently installed arch. Noticed that when shutting it down often a "A stop job is running for session 3 of root.." message appears which takes 1:30 minutes to dissapear. Further investigation ...
1
vote
1
answer
3k
views
What is the logic of using $($(nproc) + 1) in make command?
I was trying to install OpenCV in Ubuntu based on few guides online. One of the guides is this one. It has the following line:
make -j $(($(nproc) + 1))
The nproc returns the number of processors/ ...