HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting
Operating System - HP-UX
1833883
Members
1860
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
06-14-2007 10:12 PM
06-14-2007 10:12 PM
Scripting
I have been given the task to write scripts to get BDF, yesterdays syslog ( critical erros) and any users who are logged in since yesterday.
I am new to scripting so will need help with my scripting.
Below is what I tried and works OK but this is not a clever script and the problem is it is OK if I run this script Tuesday to Friday ( as I will get the logs from the previous working day) but on Mondays I will need logs from Friday, Saturday and Sunday.
Can someone help me to write better script then the one below
I also need to email this report everyday
#!/bin/sh
yesterday=`TZ=GMT+23 date | cut -d " " -f 2,3`
HOSTNAME=`uname -n`
echo "This is $HOSTNAME server"
echo "========================"
echo
echo "bdf output of $HOSTNAME"
bdf
echo
echo "Syslog for $HOSTNAME"
echo "========================="
cat /var/adm/syslog/syslog.log | grep "$yesterday" | grep -i -E 'crit|warn|ems|full'
echo "Database errlog for $HOSTNAME"
echo "========================="
cat /uv/errlog | grep "$yesterday"
# Ensure that yesterday's users killed by IT Operations"
echo "Yesterday's users who are still logged in on $HOSTNAME"
echo "======================================="
last | grep "$yesterday" | sort -n -k 8
# Overnight Printing
echo
echo "Overnight Printing Status for $HOSTNAME"
echo "================================="
lpstat -o
#mailx -s "Report" ask@test.com < /home/ask/report.log
I am new to scripting so will need help with my scripting.
Below is what I tried and works OK but this is not a clever script and the problem is it is OK if I run this script Tuesday to Friday ( as I will get the logs from the previous working day) but on Mondays I will need logs from Friday, Saturday and Sunday.
Can someone help me to write better script then the one below
I also need to email this report everyday
#!/bin/sh
yesterday=`TZ=GMT+23 date | cut -d " " -f 2,3`
HOSTNAME=`uname -n`
echo "This is $HOSTNAME server"
echo "========================"
echo
echo "bdf output of $HOSTNAME"
bdf
echo
echo "Syslog for $HOSTNAME"
echo "========================="
cat /var/adm/syslog/syslog.log | grep "$yesterday" | grep -i -E 'crit|warn|ems|full'
echo "Database errlog for $HOSTNAME"
echo "========================="
cat /uv/errlog | grep "$yesterday"
# Ensure that yesterday's users killed by IT Operations"
echo "Yesterday's users who are still logged in on $HOSTNAME"
echo "======================================="
last | grep "$yesterday" | sort -n -k 8
# Overnight Printing
echo
echo "Overnight Printing Status for $HOSTNAME"
echo "================================="
lpstat -o
#mailx -s "Report" ask@test.com < /home/ask/report.log
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 11:36 PM
06-14-2007 11:36 PM
Re: Scripting
Hi
If I understand correctly, you need every day an email report of the previous day.
If your script is ok, you just have what you want:
you can schedule your script with crontab, like that:
00 08 * * * /your/script
and on Monday morning you will find on your mailbox 3 different email for Friday, Saturday and Sunday report.
if you want to change the way to obtain "yesterday" date, i suggest you this script:
http://www.securebrain.com/ydate.html
that makes you free from hours limitation.
Is it enough? or you prefere to change the script?
manu
If I understand correctly, you need every day an email report of the previous day.
If your script is ok, you just have what you want:
you can schedule your script with crontab, like that:
00 08 * * * /your/script
and on Monday morning you will find on your mailbox 3 different email for Friday, Saturday and Sunday report.
if you want to change the way to obtain "yesterday" date, i suggest you this script:
http://www.securebrain.com/ydate.html
that makes you free from hours limitation.
Is it enough? or you prefere to change the script?
manu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 11:40 PM
06-14-2007 11:40 PM
Re: Scripting
Welcome to the forum!
Kindly change your name to something meaningfull, or sign with a name, even if just pretent, such that we do not have say 'hey you'.
>> I am new to scripting so will need help with my scripting.
1) everything has been done before.
Use that, at least as a starting point.
2) search for examples which might be close.
If you'd like to look here for older answer first try:
try google: +site:itrc.hp.com +hpux +yesterday +syslog
and google for 'caljd'.
ditto for df/bdf
3) Read, try, read some more, try some more.
Regards,
Hein van den Heuvel
Kindly change your name to something meaningfull, or sign with a name, even if just pretent, such that we do not have say 'hey you'.
>> I am new to scripting so will need help with my scripting.
1) everything has been done before.
Use that, at least as a starting point.
2) search for examples which might be close.
If you'd like to look here for older answer first try:
try google: +site:itrc.hp.com +hpux +yesterday +syslog
and google for 'caljd'.
ditto for df/bdf
3) Read, try, read some more, try some more.
Regards,
Hein van den Heuvel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2007 12:52 AM
06-15-2007 12:52 AM
Re: Scripting
Hello,
I like Manuela's suggestion to simply schedule the script to run every day, and then simply read a few messages on Monday. But if you have your heart set on aggregating logs over the weekend, you will have to perform date calculations in your script. A. Clay Stephenson has written a script for just such a purpose, which I have attached to this post.
A few stylistic comments on your script:
1) Instead of printing to stdout via 'echo ...', redirect output to a file that you keep appending. Then take this file as stdin to the 'mailx' command.
2) The POSIX-mandated form of command substitution is $() over ``.
3) Do not use 'cat' to pass the contents of a file through a command pipeline when you don't need to. Many of the standard UNIX commands, such as 'grep', take an input filename as an argument. So, for example, instead of 'cat file | grep foo' do 'grep foo file'.
4) The preferred path to the POSIX shell is '/usr/bin/sh'. Note that '/bin' is a symlink to '/usr/bin' and its use is deprecated.
Here is an excellent guide to shells under HP-UX:
http://docs.hp.com/en/B2355-90046/
PCS
I like Manuela's suggestion to simply schedule the script to run every day, and then simply read a few messages on Monday. But if you have your heart set on aggregating logs over the weekend, you will have to perform date calculations in your script. A. Clay Stephenson has written a script for just such a purpose, which I have attached to this post.
A few stylistic comments on your script:
1) Instead of printing to stdout via 'echo ...', redirect output to a file that you keep appending. Then take this file as stdin to the 'mailx' command.
2) The POSIX-mandated form of command substitution is $(
3) Do not use 'cat' to pass the contents of a file through a command pipeline when you don't need to. Many of the standard UNIX commands, such as 'grep', take an input filename as an argument. So, for example, instead of 'cat file | grep foo' do 'grep foo file'.
4) The preferred path to the POSIX shell is '/usr/bin/sh'. Note that '/bin' is a symlink to '/usr/bin' and its use is deprecated.
Here is an excellent guide to shells under HP-UX:
http://docs.hp.com/en/B2355-90046/
PCS
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP