- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Any way to change subject on cron email ?
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
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
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
тАО05-24-2005 01:50 AM
тАО05-24-2005 01:50 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 01:54 AM
тАО05-24-2005 01:54 AM
SolutionSEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 02:06 AM
тАО05-24-2005 02:06 AM
Re: Any way to change subject on cron email ?
1 2 3 4 5 /some/dir/script_to_run 2>&1 | mailx -s "/some/dir/script_to_run cron output" your_email@somewhere.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 02:10 AM
тАО05-24-2005 02:10 AM
Re: Any way to change subject on cron email ?
1 2 3 4 5 /some/dir/script_to_run 2>&1 ; mailx -s "/some/dir/script_to_run cron output" your_email@somewhere.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 02:21 AM
тАО05-24-2005 02:21 AM
Re: Any way to change subject on cron email ?
The pipe will pipe the output of the script, both stdout and stderr with the 2>&1 redirect, to mailx.
The semi-colon will just run a mailx command after the cron job runs. It would likely just sit and wait for input since you aren't sending anything to the command. And you would still get the e-mail with the "cron" subject.
Try it and see what happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 04:33 AM
тАО05-24-2005 04:33 AM
Re: Any way to change subject on cron email ?
This was your example....
1 2 3 4 5 /some/dir/script_to_run 2>&1 | mailx -s "/some/dir/script_to_run cron output" your_email@somewhere.com
I do agree there should be a pipeline which SEP missed... but i think "2>&1" is not necessary when i use a pipeline to direct to another program...because "2>&1" i had use it if i wanna send the output and error to a single file, but here we are not directing to a file but to standard output which inturn is fed to mailx program through pipeline. so i think the following should just work fine...
1 2 3 4 5 /some/dir/script_to_run | mailx -s "/some/dir/script_to_run cron output" your_email@somewhere.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 07:12 AM
тАО05-24-2005 07:12 AM
Re: Any way to change subject on cron email ?
When you run a cronjob you normally DO want both STDOUT and STDERR.
If you just do:
command | mailx
You will ONLY get STDOUT.
Think of it as if you were running a command from the prompt.
Take this test for example:
# ls a* b* c* | mailx -s test you@somewhere.com
If there are no files present you will see the errors on the screen and you will get a blank e-mail.
Now try:
# ls a* b* c* 2>&1 | mailx -s test you@somewhere.com
With this you will see NO output on the screen, but you will get an e-mail with the errors in it.
The same concept holds true for cron.
If you were to do a cron job like my first example above you would get 2 e-mails. 1 e-mail would have the subject test and would be empty (assuming no files of the name a* b* c* in the directory) or would contain the list of files and the other would have the cron subject and contain the errors.
Now if you were to do my 2nd example within cron (with the 2>&1), then you would get a single e-mail with the command output and the errors, if any.
If you don't believe me, do some testing on your own.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 07:18 AM
тАО05-24-2005 07:18 AM
Re: Any way to change subject on cron email ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 07:27 AM
тАО05-24-2005 07:27 AM
Re: Any way to change subject on cron email ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 07:39 AM
тАО05-24-2005 07:39 AM
Re: Any way to change subject on cron email ?
There would NOT be two email notifications. Since all the output is being redirected into the pipe and sent to mailx, cron does not generate an email at all.
--Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2005 07:40 AM
тАО05-24-2005 07:40 AM
Re: Any way to change subject on cron email ?
sorry for overlooking this,, as i din't give a thought in the file discriptor level. When i give a second thought based on your reply, i find it logical.
Amateur that i'm , i will try this in the next opportune time when i chance upon a system. I admit that i din't use the "combined redirection" just before a pipeline and would certainly add it to the list of goodies..after a performing the test you suggested..
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 06:39 AM
тАО05-27-2005 06:39 AM
Re: Any way to change subject on cron email ?
1 2 3 4 5 /some/dir/script_to_run 2>&1 | mailx -s "/some/dir/script_to_run cron output" your_email@somewhere.com
worked great for me. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 01:38 PM
тАО05-27-2005 01:38 PM
Re: Any way to change subject on cron email ?
Bill Hassell, sysadmin