Sponsored Content
Top Forums Shell Programming and Scripting Get status of dd running in background job Post 302861237 by sea on Tuesday 8th of October 2013 11:54:47 AM
Old 10-08-2013
Pure silence (fail)
Code:
dd if=/dev/random of=/dev/zero & 2&>1 > /tmp/tmp
pid=$(ps|grep dd|awk '{print $1}')
while [[ ! "" = "$(ps|grep dd)" ]]
do     #kill -USR1 $pid
    grep "," /tmp/tmp | grep -v "+"|awk '{$2" "$3}'
done

Full spam (fail):
Code:
dd if=/dev/random of=/dev/zero & 2&>1 > /tmp/tmp
pid=$(ps|grep dd|awk '{print $1}')
while [[ ! "" = "$(ps|grep dd)" ]]
do     kill -USR1 $pid
    grep "," /tmp/tmp | grep -v "+"|awk '{$2" "$3}'
done

Meaning:
Code:
0+5 records in
0+0 records out
0 bytes (0 B) copied0 bytes (0 B) copied, 20.7462 s, 0.0 kB/s
, 2.36932 s, 0.0 kB/s
0+5 records in
0+0 records out
0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.38147 s, 0.0 kB/s
0 bytes (0 B) copied, 20.7584 s, 0.0 kB/s
0+20 records in
0+0 records out
0 bytes (0 B) copied, 49.2783 s, 0.0 kB/s

All i want to achieve is "NO 'plain-dd' output" as above, but only this part: "0 bytes (0 B) copied" so i can print it on 1 line, 'staying' that very 1 line to the user, without the console spammed.

As in $tmp contains only "20mb" -- "25mb" -- "50mb" ...
Once i could 'mute' the DD output to the user, but still retrieve the values, even with the 0+0 records, i could 'cut' it down to the value needed, but this redirection stuff drives me crazy!! SmilieSmilie

Last edited by sea; 10-08-2013 at 01:02 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Background job

Hiya, Recently I've run a few scripts in the foreground, but have realised later they should of been better nohup'd and placed in the background. I understand how to change a foreground job into a background one, but how would put the job into the nohup state? Thanks (1 Reply)
Discussion started by: rdbooth
1 Replies

2. Shell Programming and Scripting

Hw to Know the status of running JoB

Hi all, I am running a job .. and i want to know the status tht it is runnig or not .. and how can i find the jobId of my job .. I have to get it to kill my running job Pls let me know da Unix commands to do it .. i m wrking on Hp UNIX (1 Reply)
Discussion started by: ravi.sadani19
1 Replies

3. Shell Programming and Scripting

How to know the status of process running in background

I have run one shell script in background that contains a endless while loop. I am not able to know the status of that job . Please provide any command to know this. I have already used "ps -aef" , "jobs" to know it , but it didn't work. I am sure the process is running as it is generating a file... (8 Replies)
Discussion started by: sumanta
8 Replies

4. AIX

Question on background running job

Guys, We use AIX 5.3 at our work place. I only in my team have a strange problem of not able run jobs background. Other colleagues are able to run without any problem. Once I kick off background job using nohup and & command, It immediately stops. The following error I get when I run. ... (2 Replies)
Discussion started by: anandsbr
2 Replies

5. UNIX for Dummies Questions & Answers

Job Status for running shell script

Hello, I am running a shell script whose execution often takes several hours to complete. Is there way I can get some kind of status update as the job is running? Something as simple as the start and the current time stamp. Thanks, Gussi (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

6. Shell Programming and Scripting

Capturing the exit status of the script running in background

Hi All, I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script. Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies

7. UNIX for Dummies Questions & Answers

suspend a *background* running job

Is there a way to suspend (TSTP?) a job that is running in the background, _without_ first bringing it to the foreground and inputting Ctrl-Z from the keyboard? IOW, something similar to issuing the shell's bg builtin command on a job ID to resume a job that is suspended in the background,... (2 Replies)
Discussion started by: uiop44
2 Replies

8. Shell Programming and Scripting

Background Job

Hello Everyody, Having a doubt. sort file1 & when we sent a job to the background it returns Job Number PID again if we want to ... (1 Reply)
Discussion started by: knroy10
1 Replies

9. Solaris

Is user cron job running in background?

Hi, Should the user jobs specified in crontab be running in background? Cron daemon is already running in background. So I am not sure whether should the jobs (output and error messages are redirected to file) ran by it be explicitly stated to be run in background (& at end of command) if one... (1 Reply)
Discussion started by: joe_x
1 Replies

10. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy