runing commands
Is there any way of executing a command automaticaly if it dies.i run a command
'mysql -u --password=xxxxxxx logs </var/log/mysql.pipe &' and it dies after 2-3 days. can anyhow status of a command be checked and if it is not running then can it be executed automaticaly. |
write a script that checks for the status of the command and re-launches it if already dead and put it in crontab to run automatically as often as you like.
|
how can i check the status of command
'mysql -u --password=xxxxxxx logs </var/log/mysql.pipe &' in a script. |
Code:
while true; do |
if i run the command
'mysql -u --password=xxxxxxx logs </var/log/mysql.pipe' (without &)while a process of this command is allready running in the background ,it start a new process of this command. output of ps is root 16886 0.1 0.0 3668 1244 pts/27 S 13:16 0:00 /opt/mysql/bin/mysql -u root --password=x xxxxxx syslog root 16946 0.0 0.0 5184 1240 pts/27 S 13:23 0:00 /opt/mysql/bin/mysql -u root --password=x xxxxxx syslog so if a run this command from a loop.will it not create another instances.please help Thanks |
Kill the current instance then run the loop. How hard was that? You're without a MySQL server for all of about 3 seconds if you're quick.
|
Assuming he is sitting infront of it all day?
I wish i could get paid for restarting a process all day :(. |
when i did this
Code:
$ ps aux |grep /usr/local/mysql Quote:
Code:
ps aux |grep /usr/local/mysql [EDIT] it seems Code:
$ ps aux |grep /usr/local/mysql Quote:
[/EDIT] |
Thanks everybody
I have created a script and put this code in it while true; do mysql -u root --password=xxxxxxx logs </var/log/mysql.pipe done and ran it. it is working. now whenever this process get killed a new process get started automatically. |
prozac if i run ps aux |grep /usr/bin/mysql and then echo $? it will always give 0 because command
ps aux |grep something will allways run successfully whether it find a process or not. so variable $? will allways contain 0 (for successfully running command). |
All times are GMT -5. The time now is 06:49 PM. |