- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- script to grep specifics out of sulog
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
Discussions
Discussions
Discussions
Forums
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
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
тАО08-04-2005 09:11 AM
тАО08-04-2005 09:11 AM
Looking to make a very simple script that simply will be called by cron to cat the sulog to grep for a certain user. Could someone help as I'm quite "green" to scripting?
Thanks,
KPS
Solved! Go to Solution.
- Tags:
- sulog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2005 09:15 AM
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2005 09:16 AM
тАО08-04-2005 09:16 AM
Re: script to grep specifics out of sulog
That's really it. Nothing facy needed. That will return the entire line with "user" on it. Just put the appropriate user name in place of "user".
If you want this in a script:
# cat grep_su
#!/usr/bin/sh
grep user /var/adm/sulog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2005 09:22 AM
тАО08-04-2005 09:22 AM
Re: script to grep specifics out of sulog
If you want it to be called from cron, you probably want to email the results to yourself. Here is a one line command that you can place in cron. Or if you want a script, you can place this in a script file as per the examples above.
grep user /var/adm/sulog | mailx -s "sulog user report" _admin_
Otherwise, cron will email an "error" that the job produced output.
NOTE: substitute _admin_ with whatever email address you need.
-- Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2005 09:46 AM
тАО08-04-2005 09:46 AM
Re: script to grep specifics out of sulog
Be sure to create a file called lastline with 0 in the first line to start. This way you'll only be given new lines each time it is run. Also to be sure to modify the grep part to contain the strings that you want to see.
#!/bin/ksh
# Get the last line read to only print out new lines
LASTLINE=`cat lastline`
CURLINE=0
# Read in all the syslog and only grep for desired strings past last line
cat /var/adm/syslog/syslog.log |while read LINE ;do
((CURLINE=CURLINE+1))
[[ $CURLINE -gt $LASTLINE ]] && echo "$LINE" |grep -E 'ftp|syslogd|inetd'
done
# Save out the last line read
echo $CURLINE > lastline