#1 (permalink)  
Old 11-29-2007, 07:29 PM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
what is /dev/null 2>&1 ?

Hi,

I have a problem where I have set up a cron to mail me when my mysql is down...
I now receive emails every 20 minutes but the problem is that it mails me blank emails, that means even if the mysql is not down I receice BLANK emails. What cron should I set up so that I will receive emails only if mysql is down ??
my cron:

*/20 * * * * /usr/bin/php /home/username/public_html/admin/mysqlstat.php

Also as my subject line suggests what is what is /dev/null 2>&1 ? does that relates to my query above ??? Please help...
__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-29-2007, 08:22 PM
darren.nolan's Avatar
Registered User
 
Join Date: Oct 2007
Posts: 259
darren.nolan is on a distinguished road
I believe cPanel will send you an email every 5 minutes if one of your monitored services is down - Under WHM -> Service Manager -> Ensure the box to monitor MySQL is selected.

With your cron - change it to;

*/20 * * * * /usr/bin/php -q /home/username/public_html/admin/mysqlstat.php

-q is quiet or not header mode (might explain why you are getting blank emails?) - and have your mysqlstat.php file generate an email if the service is down.

From LinuxHelp.net http://www.linuxhelp.net/guides/cron/
>> /dev/null 2>&1 part means to send any standard output to /dev/null (the linux trash can) and to redirect standard error (2) to the same place as the standard output (1). Basically it runs the command without any output to a terminal etc.

Hope this helps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-30-2007, 02:17 PM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by darren.nolan View Post
I believe cPanel will send you an email every 5 minutes if one of your monitored services is down - Under WHM -> Service Manager -> Ensure the box to monitor MySQL is selected.

With your cron - change it to;

*/20 * * * * /usr/bin/php -q /home/username/public_html/admin/mysqlstat.php

-q is quiet or not header mode (might explain why you are getting blank emails?) - and have your mysqlstat.php file generate an email if the service is down.

From LinuxHelp.net http://www.linuxhelp.net/guides/cron/
>> /dev/null 2>&1 part means to send any standard output to /dev/null (the linux trash can) and to redirect standard error (2) to the same place as the standard output (1). Basically it runs the command without any output to a terminal etc.

Hope this helps
Hiya,

Thanks for your response on this, but I am using this cron for a client ..hosted on the server.

I simply want to make the cron email him only if there is a failure or errors with mysql server... I do not want the BLANK emails every 20 minutes...

Please help....
__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-30-2007, 02:47 PM
Registered User
 
Join Date: Nov 2007
Posts: 21
rbalaji is on a distinguished road
Lightbulb

Hi,

no worries,
You can set it up directly in crontab file. Open your crontab file and assign the cron mail address for him .
The format looks like..
-----------------
]crontab -e <username>
MAILTO=username@domain.com
*/20 * * * * /usr/bin/php -q /home/username/public_html/admin/mysqlstat.php
----------------


Thanks

Last edited by rbalaji; 11-30-2007 at 02:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-30-2007, 03:52 PM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by rbalaji View Post
Hi,

no worries,
You can set it up directly in crontab file. Open your crontab file and assign the cron mail address for him .
The format looks like..
-----------------
]crontab -e <username>
MAILTO=username@domain.com
*/20 * * * * /usr/bin/php -q /home/username/public_html/admin/mysqlstat.php
----------------


Thanks
Hi rbalaji,

Thanks, but I have already set that up and I am receiving this BLANK emails even if mysql is not down or have any errors with it.........

One thing to note that the cron does send emails when there is a mysql failure...

so in short here how it goes.

cron emails when....

there is a failure with mysql
there is no mysql failure....BLANK email <---

I do not want cron to email me when is no mysql failure.......



Hope I am clear this time....

Please help..
__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-01-2007, 12:21 AM
darren.nolan's Avatar
Registered User
 
Join Date: Oct 2007
Posts: 259
darren.nolan is on a distinguished road
I stress the -q after /php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 12-03-2007, 01:45 AM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by darren.nolan View Post
I stress the -q after /php
I tried the above to no avail...Still receiving the blank emails....

please help....

I don't think this works with cron..... is it ?
__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 12-03-2007, 04:37 AM
darren.nolan's Avatar
Registered User
 
Join Date: Oct 2007
Posts: 259
darren.nolan is on a distinguished road
What is your PHP script?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 12-03-2007, 10:14 PM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by darren.nolan View Post
What is your PHP script?
Hi,

attached is the script......

It used to work but now suddenly its not.....

cron set as:

*/20 * * * * /usr/bin/php -q /home/username/public_html/admin/mysqlstat.php

Any other alternative besides php -q ? like wget, get .....
Attached Files
File Type: txt mysqlstat.txt (10.3 KB, 11 views)
__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 12-04-2007, 10:22 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by cpane1 View Post
...

Any other alternative besides php -q ? like wget, get .....
One method I used for a long time was placing the script in public_html (like Drupal does with its cron script) then call lynx to request that "page".

Another alternative is to make your PHP script a PHP shell script. That'd mean placing a hashbang at the top of the file as you would with a Perl script, except calling the PHP binary instead. If you don't want to echo output, use the -q parameter in there as well.

In my own scripts though, when I want an email about something, I put in my own calls to mail() rather than relying on some implicit functionality of cron.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 12-04-2007, 10:54 PM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by cPanelDavidG View Post
In my own scripts though, when I want an email about something, I put in my own calls to mail() rather than relying on some implicit functionality of cron.
Can you please let me know any such call (using mail() function) that can be added into the script that I have provided.....


That would be much appreciated....

__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 12-05-2007, 06:13 AM
brianoz's Avatar
Registered User
 
Join Date: Mar 2004
Location: Melbourne, Australia
Posts: 984
brianoz is on a distinguished road
Google is your friend or php.net/mail, or phpfreaks, or sitepoint ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 12-05-2007, 07:24 AM
darren.nolan's Avatar
Registered User
 
Join Date: Oct 2007
Posts: 259
darren.nolan is on a distinguished road
Quote:
Originally Posted by brianoz View Post
Google is your friend or php.net/mail, or phpfreaks, or sitepoint ...
mmm -sitepoint.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 12-05-2007, 10:13 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
php.net/insert function name here is definitely a useful resource for PHP scripting, especially the user-contributed comments.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit

Last edited by cPanelDavidG; 12-05-2007 at 10:14 AM. Reason: Combatting auto-linking
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 12-07-2007, 03:33 AM
Registered User
 
Join Date: Jun 2007
Posts: 41
cpane1 is on a distinguished road
Quote:
Originally Posted by cPanelDavidG View Post
php.net/insert function name here is definitely a useful resource for PHP scripting, especially the user-contributed comments.

Thanks for all your help...... but all seems to be in vain as the client want that script and no other way round.. he says it USED to WORK.. and now its not....
I don't understand whats changed on the server ......

also does cron really does what the client really looking for ??? this is a BIG question.....

guys..come one help me in this......


__________________
Warm Regards,
cPane1®
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© cPanel Inc