Questions tagged [jobs]

Job control in a shell

Filter by
Sorted by
Tagged with
1
vote
1answer
34 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
1answer
63 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 ...
0
votes
0answers
22 views

kill can't kill background process in script

For a reason sudo pkill $(jobs -p 1) can't kill the process but sudo pkill works outside the script #!/bin/bash pipe=/tmp/outpipe_vpn mkfifo $pipe ##random command to enter sudo password sudo echo ...
-1
votes
1answer
28 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
0answers
55 views

anacron does not run scripts from the cron.daily folder

As per title, why doesn't anacron run the scripts from the cron.daily folder? And,what are those "runs-parts" inside /etc/anacrontab? Shouldn't they run the scripts contained in cron.daily, ...
0
votes
0answers
26 views

Is there a way to start a few tasks in Bash or Zsh, within the shell's job control?

Short question is, is there a way to group several tasks and start them, and be able to control them using job control commands, such as jobs and kill %1? (I need to stop them easily). Details: ...
0
votes
0answers
94 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
0answers
51 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 ...
3
votes
1answer
39 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
1answer
36 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
1answer
35 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
1answer
123 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
1answer
19 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
2answers
62 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
0answers
29 views

Cron Job is running outside of defined schedule

I have a question and am relatively new to scheduling Cronjobs in R Studio. I have an R script that I would like to run every Monday - Friday, every 1 minute, and between the hours of 9 - 16 (9 am to ...
0
votes
2answers
60 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
1answer
73 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
0answers
51 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
1answer
34 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
1answer
95 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
1answer
257 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
2answers
189 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
0answers
87 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
0answers
99 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
1answer
85 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
1answer
394 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
0answers
51 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
1answer
800 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 ...
2
votes
0answers
301 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
1answer
687 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
1answer
887 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 ...
0
votes
1answer
2k 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/ ...
13
votes
4answers
5k views

What happens if I start too many background jobs?

I need to do some work on 700 network devices using an expect script. I can get it done sequentially, but so far the runtime is around 24 hours. This is mostly due to the time it takes to establish a ...
4
votes
4answers
2k views

Command for “wait for the job to finish and then begin another job”? [duplicate]

Without knowing ahead of time that I'll want to do this, is it possible to wait for a job to finish and automatically begin executing another one? For example, I jump into a tmux session and execute ...
1
vote
0answers
26 views

Why does my job control fail inside a loop? [duplicate]

My bash script is supposed to start a process (let's say, run less) and bring it back to foreground every time the process is suspended (e.g. by pressing CTRL-Z). If I just keep repeating the ...
1
vote
1answer
153 views

Does a shell which does not support job control has the concept of foreground and background processes?

I used to think that only if a shell supports job control, can it has the concept of "foreground" and "background" processes (group). But I read a paragraph indicating that's not true. From APUE § 10....
3
votes
0answers
1k views

List all jobs in all shell sessions (not just the current shell), by current user

I know that the jobs command only shows jobs running in current shell session. Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for ...
1
vote
1answer
84 views

How to get variables expanded in output of jobs command

As you can see in the following output the variable $i in the output of ps aux is expanded to sleep 1, sleep 2, etc. Is there a way to make zsh do the same? In the jobs output all the commands get the ...
0
votes
1answer
2k views

How to check which process is writting on FileSystem Solaris

I need to identify what process is writing non-stop on the Disk. I tried to run prstat -t to get the list of the processes running, but I can't identify/find which process it is. running df -k , I ...
1
vote
1answer
307 views

Making zsh jobs -p behave as in bash

Is there a way to make jobs -p in zsh behave as in bash, ie. give only a number, such that one can do kill $(jobs -p)?
20
votes
5answers
10k views

How to plan a task to run after another already running task in bash? [duplicate]

I'm looking for something like command1 ; command2 i.e. how to run command2 after command1 but I'd like to plan execution of command2 when command1 is already running. It can be solved by just typing ...
0
votes
1answer
37 views

copy numerous files/folders in linux with queuing and the ability to break and continue

I'm copying terabytes worth of data from an OLD OLD OLD *nix system. I could spend the money to buy new hardware to plug the drives into but I want to avoid spending money. The system is crappy. It ...
0
votes
1answer
39 views

Submitting HPC jobs within an HPC job

I have a large script which relies on input arguments (with getopts). One of these arguments is a directory containing files (all named *bam) This script has 2 parts: Part1: based on input *bam ...
0
votes
1answer
188 views

Asynchronous background jobs in linux can interfere to each other?

I was trying to use a linux command repeatedly and I decided to use bash scripting. The command is curl and it has blue screen given to the target web server. I was doing this as a pentester in my ...
0
votes
1answer
83 views

How can I periodically record the dir stack and jobs of a shell without occupying the shell?

I have a script $ cat my.sh #! /bin/bash - dirs -l > /tmp/test/dirs_record jobs > /tmp/test/jobs_record So when I source ./my.sh, it will output the dir stack and jobs in the invoking shell. ...
2
votes
2answers
204 views

Jobs not appearing in `jobs`

I have a script called go.sh python3 bob.py &> lol.log & python3 alice.py &> lol2.log & When I run ./go.sh and then run jobs. Neither one of the jobs that I've executed in go....
1
vote
1answer
630 views

In bash, a process group is a job if and only if …?

Here are two cases when a process group in an interactive shell isn't a job of the shell: $ sleep 100 & [1] 16081 $ jobs [1]+ Running sleep 100 & $ disown %1 $ jobs $ and $ ...
-3
votes
1answer
59 views

Remove all scheduled before 17:00 jobs with atrm [closed]

I need a shell script that removes all scheduled before 17:00 jobs with the user name as a positional parameter This is what I tried to do #!/bin/bash currentTime = ‘date + %k%M’ check_time_tu_run() {...
0
votes
1answer
81 views

Linux review T background job

user 23110 0.1 1.7 615392 73004 pts/2 T 20:57 0:13 process I have a process what I put in the background on a terminal which froze after. Not responsive for keys/reset/commands etc. I ...
1
vote
1answer
3k views

How can we kill all the background jobs (running or not) in the current shell?

From https://unix.stackexchange.com/a/43709/674 To just kill all background jobs managed by bash, do kill $(jobs -p) Does kill $(jobs -p) kill only those "running" background jobs in the current ...