ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok, I am getting dangerous now, but we have a problem with an apache memory leak and it's taking out the box's. So for now I am babysitting them using a free -m across the network, getting the swap in use, if it's over 300 or so, restarting apache (long story). While the developers track down, I would like to set this up as a script to check, if over 300 send an email, so this;
free -m | awk '/Swap/ {print $3}'
gives me exactly what I want, so now I need to say in a script;
if free -m | awk '/Swap/ {print $3}' > 300
{
email me
}
, then stick that in a cron. I know php, cf, etc. so this will take the right person/people 2 min's to reply vs. me starting at page 1, hello world.
thanks, I put that in my home, made it executable, and ran it;
./memchk.sh <enter> and it just sat there. I put it on a box that had a swap in use of around 300 (so it would trip it) and it just sat there. A <ctrl>-C showed, (Interrupt -- one more to kill letter)
but it never sent the email.
I also upped the limit to 500 so it wouldn't trip, ran and it went through back to command line, so it must be something missing like a ', ; etc.
But thanks for the quick reply, just need to kick it one more time!
Just for future reference, it wasn't working because the first mail command i gave you didn't contain any text in the main body of the email, i thought that an email with just a subject name should send but it appears not to, hense why i then went and tried a input re-direct into the mail which does work but yes, using a pipe as the input also works so either way would have worked the '|' method is much neater :-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.