- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ksh logging
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
01-21-2004 07:50 AM
01-21-2004 07:50 AM
0 0 * * 6 su back -c /home/back/scripts/backup/backup_db.sh > /home/back/log/backup_db.log.`date +\%j`
My problem is is that the script is in ksh, this script call 3 other scripts.
I would like to have all the output emailed to me, (and later, only email if I get an error from any of the scripts that ran).
How do I set logging in backup_db.sh and at the end mail the file.
I am sure there is a better way to do this, but any help would be appreciated.
All the scripts are done in ksh, yes, I would like to go to perl, but, not at this time...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2004 08:05 AM
01-21-2004 08:05 AM
SolutionThis is one of the solutions.
0 0 * * 6 su back -c /home/back/scripts/backup/backup_db.sh > /home/back/log/backup_db.log.`date +\%j` 2>&1; mailx -s "Details of backup" your_id@yourdomain.com < /home/back/log/backup_db.log.`date +\%j`
The above will mail all the details.
Later for only error log
0 0 * * 6 su back -c /home/back/scripts/backup/backup_db.sh > /home/back/log/backup_db.log.`date +\%j` 2>/home/back/log/backup_db.err.`date +\%j`; mailx -s "Details of backup" your_id@yourdomain.com < /home/back/log/backup_db.err.`date +\%j`
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2004 08:13 AM
01-21-2004 08:13 AM
Re: ksh logging
For example,
exec 1>/var/tmp/mylog 2>&1
ls
echo "Test"
ls Badfile
will combine stdout and stderr onto /var/tmp/mylog. Put the exec at the top of your script and stdout/stderr will be sent to the file. At the end of your script test to see whether mylog is non-empty and if so mail the contents of that file and then remove it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2004 08:13 AM
01-21-2004 08:13 AM
Re: ksh logging
su back -c /home/back/scripts/backup/backup_db.sh | tee /home/back/log/backup_db.log.`date +\%j`
What tee does in this context is to write stdout to the file (just like before) but also echo everything written to the file to stdout so it will be emailed. As far as all output versus only errors, you control this in your script(s). Set a variable, perhaps ERRORONLY to be tested and echo or print information only when it is false. To test everything, set ERRORONLY to true and you should see only errors (that is, text sent to stderr in your script). Set it to false and you'll see every echo and print sent to stdout.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2004 08:20 AM
01-21-2004 08:20 AM