Re: OT: renice jobs running for more than 5 minutes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 22 Feb 2016 10:38:30 -0800 Rick Stevens <ricks@xxxxxxxxxxxxxx> wrote:

> On 02/22/2016 10:19 AM, Ranjan Maitra wrote:
> > Hi,
> >
> > I am running a fully updated F23 box but this question does not have much to do with Fedora itself, hence the designator and the disclaimer.
> >
> > I am wanting to run a script which will look at all the jobs that are running and renice all of them which have been on for more than five minutes. (Then I can run the script as a cron job as root and be done with automating the process.)
> >
> > Are there any suggestions as to how to go about this task efficiently? Actually, before I reinvent the wheel, are there any standard options that already exist and which would be more suitable for me than just to do everything from scratch.
> 
> Use the "-o pid,etimes=" options of ps to get the elapsed time of
> tasks in seconds. To get a full list, for example, as root:
> 
> 	ps ax -o pid,uid,etimes=
> 	...
> 	21412     0     833
> 	21499     0  631433
> 	21541     0     773
> 	21597  1000     769
> 	21604  1000     769
> 	21605  1000     769
> 	21608  1000     769
> 	21610  1000     769
> 	21613  1000     769
> 	21681  1000     769
> 	21686  1000     769
> 	21697  1000     769
> 	21751  1000     742
> 	...
> 
> (run it as root so you can see ALL of the processes)
> 
> As you can see, you get three columns: the first is the PID of the
> task, the second is the EUID of the user running it, and the third is
> the elapsed time.
> 
> So, pull that data into a shell array, look for stuff that has the
> second column equal to the user ID you're interested in and the third
> column >= 300 seconds and renice the PID in the first column. Note that
> I'd avoid renicing any tasks with UIDs < your lowest normal user ID
> (typically 100) to keep from starving system tasks.
> 
> Hope that helps!

Yes, this absolutely helps, thanks!! But is there a 2-d array in bash (or do we do array of arrays)? (I am presuming that I need to store this in a 2-d array and then look at columns 2 and 3  and renice the PIDs in column 1.) Also, how does one assign the output of the ps to a 2-d array? 

Many thanks again and best wishes!
Ranjan

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
Check it out at http://www.inbox.com/marineaquarium


-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux