- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Strange shell script behaviour
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
03-09-2006 01:10 AM
03-09-2006 01:10 AM
Strange shell script behaviour
Apparently my script only work if I run it in foreground but not cron. It seem to be something to do with the remote ssh execution, the output was not captured.
PATH=/usr/bin:/opt/openssh/bin:
export PATH
rm -f /tmp/sarcheck
ssh username@hostname "sar -u 30 5" > /tmp/sarcheck
IDLE=`cat /tmp/sarcheck | grep Average | awk '{print $5}'`
function func_send_email
{
(
echo "To:myemail@my.com"
echo "Subject:CPU Alert idle"
) | /usr/sbin/sendmail -t
}
echo $IDLE >> /tmp/cpu.log
if [ $IDLE -lt "10" ]
then
echo "Warning High CPU more than 90%"
func_send_email
fi
please advise
- Tags:
- cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 01:25 AM
03-09-2006 01:25 AM
Re: Strange shell script behaviour
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 01:43 AM
03-09-2006 01:43 AM
Re: Strange shell script behaviour
For looking problems with scrits running by cron, try redirect errors messages e default output:
0,15,30,45 * * * * /your_script.sh >/tmp/output.txt 2>/errors.txt
You can put "set -x" in the begin of the script for debug.
Remember when you submit script for cron, is possible see this output:
"warning: commands will be executed using /usr/bin/sh"
Sometimes a script run well in korn shell, but not run so well in posix shell.
Schimidt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 01:08 PM
03-09-2006 01:08 PM
Re: Strange shell script behaviour
+ rm -f /tmp/sarcheck
+ ssh user@hostname sar -u 30 5
+ 1> /tmp/sarcheck
You have no controlling tty. Cannot read passphrase.
+ + cat /tmp/sarcheck
+ grep Average
+ awk {print $5}
IDLE=
+ echo
+ 1>> /tmp/cpu.log
+ [ -lt 10 ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 04:01 PM
03-09-2006 04:01 PM
Re: Strange shell script behaviour
Can you try "ssh" with "-T" option.
This is what I read related to "-T" option...
"-T Disable pseudo-tty allocation."
Regards,
Senthil Kumar .A