|
|||
|
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® |
|
||||
|
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
|
|
|||
|
Quote:
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® |
|
|||
|
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. |
|
|||
|
Quote:
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® |
|
|||
|
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® |
|
|||
|
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 .....
__________________
Warm Regards, cPane1® |
|
||||
|
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 |
|
|||
|
Quote:
That would be much appreciated....
__________________
Warm Regards, cPane1® |
|
||||
|
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 |
|
|||
|
Quote:
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® |
![]() |
| Thread Tools | |
| Display Modes | |
|
|