- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: I need some help w/automating a script in cron...
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
02-10-2006 07:43 AM
02-10-2006 07:43 AM
This is one script:
johnsonr@nmscrme01 > cat emdsils1.sh
#!/bin/sh
for device in `cat /opt/home/johnsonr/scripts/perl/emdsils1-node`
do
/opt/home/johnsonr/scripts/perl/emdsils1 $device
done
johnsonr@nmscrme01 >
The other scripts are named emdsils2.sh, emdsils3.sh, egaglks1.sh, egaatls1.sh.
This would be the crontab entry for one script.
00 6,8,10,12,14,16,18,23 * * * /opt/home/johnsonr/scripts/perl/emdsils1.sh
However, I don’t know how to have the contents of the output emailed. I’m guessing the output from each script would need to be written to a file and then emailed out.
Also, I don’t know if the output should be written to the file somewhere in the .sh scripts that basically read a perl script and also get hostnames from the emdsils1-node file.
Ideas on how I could accomplish this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 07:47 AM
02-10-2006 07:47 AM
SolutionJeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 07:52 AM
02-10-2006 07:52 AM
Re: I need some help w/automating a script in cron and emailing the output -
echo "Message" | sendmail -v user@email
echo "Message" | mailx -s 'subject' user@email
echo "Message" | elm -s 'subject' user@email
echo `date` | mailx -s 'subject' user@email
(echo "Subject: e-mail subject here" ; echo "test body message") | sendmail user@email
Hope this helps!
james
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 07:57 AM
02-10-2006 07:57 AM
Re: I need some help w/automating a script in cron and emailing the output -
With crontasks, any un-redirected STDOUT or STDERR is automatically mailed to the user.
In that respect you may not need to do anything.
Otherwise you can send mail to one or more users like this:
# mailx -s "You have mail!" root < yourfile
If you want to add Rob to the mail above, you could do:
# mailx -s "You have mail!" root,rob < yourfile
If you are creating temporary files in your scripts, its a good idea to include the process id (pid) as part of the filename. Use the "$$" shell variable to do that:
# echo "My notes..." > /tmp/mysh.$$
As for labeling your mail with the script name and date of the run, do something like:
# echo "I am $0 run at `date '+%D %T'`"
The shell variable $0 gives your process name.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 08:16 AM
02-10-2006 08:16 AM
Re: I need some help w/automating a script in cron and emailing the output -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 09:36 AM
02-10-2006 09:36 AM
Re: I need some help w/automating a script in cron and emailing the output -
Thanks for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2006 09:40 PM
02-10-2006 09:40 PM
Re: I need some help w/automating a script in cron and emailing the output -
this is what i usually put when i have to send an attachment from a script (cron)
/usr/bin/uuencode $LOG_PATH/process"$dt".log "process.log"|mailx -m -s "Mail header for - `date`" $EMAILADD
where $LOG_PATH and $EMAILADD are environment variables.
hope this helps too!
kind regards
yogeeraj