How to check same process running 10 times?

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 15  
Old 11-10-2017
Thanks a lot for ur quick respond Am runing below script passing 1 because no duplicate job runing now it giving correct output-AIX operating system

my question::Will it work if runing more then 10 time or will it compaire please confirm
Code:
awk '++s[$2]==10'

Code:
jobs=$(ps -u pintu -o pid= -o args=| awk '++s[$2]==1')
if [[ -n "$jobs" ]]
then
  printf "jobs runing longtime:\n%s\n" "$jobs"
  exit 1
fi

see the below output also
Code:
jobs runing longtime:
 2362 /usr/bin/gnome-keyring-daemon --daemonize --login
 2371 gnome-session
 2380 dbus-launch --sh-syntax --exit-with-session
 2381 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
 2399 /usr/libexec/gconfd-2
 2406 /usr/libexec/gnome-settings-daemon
 2408 seahorse-daemon
 2415 /usr/libexec/gvfsd
 2423 metacity
 2434 /usr/bin/pulseaudio --start --log-target=syslog
 2435 gnome-panel
 2440 /usr/libexec/pulse/gconf-helper
 2441 nautilus
 2443 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=18
 2453 /usr/libexec/gvfs-gdu-volume-monitor
 2454 /usr/libexec/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-fd=18
 2455 /usr/libexec/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory --oaf-ior-fd=24
 2459 /usr/lib/vmware-tools/sbin32/vmtoolsd -n vmusr --blockFd 3
 2467 gpk-update-icon
 2470 gnome-power-manager
 2474 gnome-volume-control-applet
 2476 bluetooth-applet
 2480 /usr/sbin/restorecond -u
 2482 /usr/libexec/polkit-gnome-authentication-agent-1
 2485 python /usr/share/system-config-printer/applet.py
 2486 /usr/libexec/gdu-notification-daemon
 2489 nm-applet --sm-disable
 2494 /usr/libexec/gvfs-afc-volume-monitor
 2498 /usr/libexec/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0
 2502 /usr/libexec/gvfs-gphoto2-volume-monitor
 2509 gnome-screensaver
 2518 /usr/bin/gnote --panel-applet --oaf-activate-iid=OAFIID:GnoteApplet_Factory --oaf-ior-fd=23
 2519 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=29
 2520 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationAreaApplet_Factory --oaf-ior-fd=39
 2521 /usr/libexec/gdm-user-switch-applet --oaf-activate-iid=OAFIID:GNOME_FastUserSwitchApplet_Factory --oaf-ior-fd=35
 2562 /usr/libexec/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1
 2569 /usr/libexec/gvfsd-metadata
 2575 /usr/bin/gnome-terminal -x /bin/sh -c cd '/home/pintu/Desktop' && exec $SHELL -l
 2576 gnome-pty-helper
 2577 /bin/bash -l
 2843 sh t2.sh
 2845 ps -u pintu -o pid= -o args=
 2846 awk ++s[$2]==1

# 16  
Old 11-15-2017
The
Code:
awk '++s[$2]==10'

lists the 10th occurrence of column#2, and if there are more than 10 it will not wipe a previously printed one Smilie
You can search for certain strings through the whole line like this
Code:
awk '(index($0, "a.ksh") || index($0, "d.ksh") && ++s[$2]==10'

and this should work with the args.
Regarding "jobs running longtime", perhaps etime (elapsed time) is more interesting:
Code:
ps -e -o pid= -o etime= -o args=

And now your task is to have the postprocessor (awk) compute a comparible number from the etime column.
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Check if process is running if not then use command kotch Shell Programming and Scripting 2 09-23-2018 03:57 AM
Looping to check the currently running process. ankitknit Shell Programming and Scripting 1 12-27-2012 04:18 AM
How a process can check if a particular process is running on different machine? saurabhnsit2001 UNIX for Dummies Questions & Answers 2 06-03-2012 12:14 AM
need to check if the process is running shifahim Shell Programming and Scripting 8 08-18-2011 11:17 PM
Script to check running of process lovepujain Shell Programming and Scripting 2 04-25-2011 03:39 AM
How do I check if a process is running in C cprogdude Programming 1 10-12-2010 06:01 AM
Command to check if a particular process is running vr3w3c9 UNIX for Dummies Questions & Answers 6 05-31-2010 07:38 AM
How to check if process is running? ladyAnne UNIX and Linux Applications 5 05-01-2010 02:20 AM
Check if Process is running Raynon Shell Programming and Scripting 3 01-08-2010 03:03 AM
How to check since when (for how long) a particular process is running ? hpuxlxboy UNIX for Advanced & Expert Users 2 02-19-2009 08:14 AM
script to check if process is running daydreamer Shell Programming and Scripting 2 01-28-2009 06:14 PM
how to check how long the process has been running. ukatru UNIX for Advanced & Expert Users 2 08-17-2008 09:22 PM
Check whether ftpd process is running or not? The.White.Rider Solaris 8 06-17-2008 08:51 AM
check process running rose1207 Shell Programming and Scripting 4 12-28-2007 01:23 AM
How to check if another instance of the process is running sim Shell Programming and Scripting 8 06-30-2005 08:24 AM
All times are GMT -4. The time now is 04:09 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?