Sponsored Content
Full Discussion: Using the watch command
Top Forums Shell Programming and Scripting Using the watch command Post 302991491 by SkySmart on Saturday 11th of February 2017 02:28:42 PM
Old 02-11-2017
Using the watch command

so i have a very long script which i have to run. when i run this script, i want to monitor the the openssl commands it runs.

the way ive attempted to do this is:

Code:
watch -t -n 1 "(date '+TIME:%H:%M:%S' ; ps aux | egrep openssl | egrep -v grep)" 2>&1 | tee -a logfile

the above command is suppose to run the watch command continuously looking for the word "openssl" in the process table.
when it finds any process that has the word, its suppose to copy the entire line from the process table containing the "openssl" command and then log it to a file called logfile.

however, this isnt working as expected. when i view the logfile all i see is a bunch of empty lines and blank spaces and these weird characters:

Code:
;80H^[[1;13H1^[[24;80H^[[1;13H2^[[24;80H^[[1;13H3^[[24;80H^[[1;13H4^[[24;80H^[[1;13H5^[[24;80H^[[1;13H6^[[24;80H^[[1;13H7^
[[24;80H^[[1;13H8^[[24;80H^[[1;13H9^[[24;80H^[[1;12H40^[[24;80H^[[1;13H1^[[24;80H^[[1;13H2^[[24;80H^[[1;13H3^[[24;80H^[[1;13H4^[[24;80H^
[[1;13H5^[[24;80H^[[1;13H6^[[24;80H^[[1;13H7^[[24;80H^[[1;13H8^[[24;80H^[[1;13H9^[[24;80H^[[1;12H50^[[24;80H^[[1;13H1^[[24;80H^[[1;13H2^[
[24;80H^[[1;13H3^[[24;80H^[[1;13H4^[[24;80H^[[1;13H5^[[24;80H^[[?1049h^[[1;24r^[(B^[[m^[[4l^[[?7h^[[H^[[2J^[[24;80H^[[?1049h^[[1;24r^[(B^[[m^[[4l^[[?7h^[[H^[[2J^[[24;80H

how can the watch command be fixed to do what i want?
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Linux watch command on AIX?

On Linux I could use the `watch` command to loop a command X times. Is there a similar command on AIX? If not, is there a way to write a loop on the command line to do this? Linux: watch -d -n 60 'db2 list applications show detail | grep Connect | wc -l' AIX: ??? (2 Replies)
Discussion started by: djschmitt
2 Replies

2. Solaris

Any command to watch output repeatedly??

Hi Experts,, Can you tell me "Is there any command in solaris that gives the output repeatedly for every x seconds" when used with other commands like ls,du,df,etc..Like prstat updates its output for every 5 seconds.. If i want to view how much of disk usage is going on a filesystem for every... (2 Replies)
Discussion started by: sdspawankumar
2 Replies

3. Shell Programming and Scripting

Folder Watch

Hi there, I was wondering if there was a way in UNIX that I could set up a running script that monitors a certain folder (and all the folders and files contained within it) so that if any file changes then it will be the change logged within a log file. I dont know if this is possible in Unix... (6 Replies)
Discussion started by: lodey
6 Replies

4. Shell Programming and Scripting

Command similar to watch

Hi all, I am trying to create a file that shows the CPU usage, constantly updating (similar to TOP). So far i have a file (called test) containing: echo "The current CPU usage is:" `ps -e -o pcpu|awk 'NR > 0 { s +=$1 }; END {print s"%"}'` and then I ran the command: watch -d 0.5 -t... (3 Replies)
Discussion started by: mikejreading
3 Replies

5. UNIX for Dummies Questions & Answers

watch command

Hi, Please help me out! In the man pages they dont talk about any options that can be used to terminate a running 'watch' command. Do you know a way of terminating the command using an option? Thanks (1 Reply)
Discussion started by: foxtron
1 Replies

6. HP-UX

looking for a unix command for hpux - watch

watch is a common linux command that executes a program periodically, showing output fullscreen. I couldn't find anything for hpux, so I created the following shell which the user is testing: cat /usr/bin/watch #!/bin/sh while ; do clear echo "Command: $*" date echo "" ... (2 Replies)
Discussion started by: mr_manny
2 Replies

7. Shell Programming and Scripting

Use script to monitor command output question? (like Linux watch)

Hi I want to write a script, help me to monitor command output. This script like Linux "watch" command. Below is my script: # cat watch.sh #!/bin/bash while true do clear echo "command: $*" ( $* ) sleep 2 done Then I run this script below (2 Replies)
Discussion started by: nnnnnnine
2 Replies
service(8)						      System Manager's Manual							service(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the invoked script, service passes COMMAND and OPTIONS it to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. service --status-all runs all init scripts, in alphabetical order, with the status command. If the init script file does not exist, the script tries to use legacy actions. If there is no suitable legacy action found and COMMAND is one of actions specified in LSB Core Specification, input is redirected to the systemctl. Otherwise the command fails with return code 2. FILES
/etc/init.d The directory containing System V init scripts. ENVIRONMENT
LANG, TERM The only environment variables passed to the init scripts. SEE ALSO
chkconfig(8), ntsysv(8), systemd(1), systemctl(8), systemd.service(5) Jan 2006 service(8)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy