VMWARE
asked on
Shell script, for control of a process.
Hello,
I need a script to monitor that it's running only one instance of a process, and that if it's not running, then launch that process.
Thanks in advance
I need a script to monitor that it's running only one instance of a process, and that if it's not running, then launch that process.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello tel2,
"Only one instance" = Only one process. Means that's not necessary relaunch the process once again...
"Only one instance" = Only one process. Means that's not necessary relaunch the process once again...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what issues?, and how do i for avoid that issues?
I'd do it like this
#!/bin/bash
cmd="/usr/bin/php -q /var/www/AFMNnew/serviceFtp.php"
while true
do
pgrep -f "$cmd" >/dev/null || $cmd
sleep 60 # Adjust to whatever period you want to check
done
But since Tintin's script doesn't appear to be designed to be run as a cron job, if it every dies for any reason, then your FTP script no longer has life insurance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This code would be correct?.
#!/bin/bash
cnt=`pgrep $1 | wc -l`
if [ $cnt -eq 0 ]
then
/usr/bin/php -q /var/www/AFMNnew/serviceFtp.php
fi
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello tel2,
I want to check hourly...
I want to check hourly...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could you explain me a little of your shell script?..
The process is this: /usr/bin/php -q /var/www/AFMNew/serviceFtp.php
Thanks