- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can I use ps to identify processes more than 30 da...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 04:21 AM
03-23-2001 04:21 AM
Can I use ps to identify processes more than 30 days old?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 04:37 AM
03-23-2001 04:37 AM
Re: Can I use ps to identify processes more than 30 days old?
'ps' displays the starting date of a process if its older than 24 hours. So at the end of the month you could select the processes of the previous month and kill them.
good luck,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 06:00 AM
03-23-2001 06:00 AM
Re: Can I use ps to identify processes more than 30 days old?
here a quick and dirty script to do this.
(i used the touch command to have a file for every process with the same time as the pid and use find to get the older ones).
#!/bin/sh
LANG=C # set default language
mkdir -p /var/tmp/pstmp 2>&- # create temp dir
rm -f /var/tmp/pstmp/* # purge temp dir
cd /var/tmp/pstmp || exit 1
# i've added grep -v lpsched to prevent stopping the scheduler at all
ps -fulp|grep -v lpsched|awk '{
month=0;
if($5 == "Jan") month=1;
if($5 == "Feb") month=2;
if($5 == "Mar") month=3;
if($5 == "Apr") month=4;
if($5 == "May") month=5;
if($5 == "Jun") month=6;
if($5 == "Jul") month=7;
if($5 == "Aug") month=8;
if($5 == "Sep") month=9;
if($5 == "Oct") month=10;
if($5 == "Nov") month=11;
if($5 == "Dec") month=12;
if(month > 0)
printf("%s %02d%02d0000\n",$2,month,$6);
}' |while read pid stamp
do
touch -t $stamp $pid # touch a reference file for every pid
done
find [0-9]* -mtime +30 2>&-|while read pid # find files older than 30 days
do
kill $pid # kill it
done
cd /
rm -rf /var/tmp/pstmp # cleanup
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 06:39 AM
03-23-2001 06:39 AM
Re: Can I use ps to identify processes more than 30 days old?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 07:09 AM
03-23-2001 07:09 AM
Re: Can I use ps to identify processes more than 30 days old?
lpstat -t and cancel using the cancel command the job number.. that's assuming the lp user is doing lp print commands.
Later,
bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2001 08:17 AM
03-23-2001 08:17 AM