Date: Fri, 6 Dec 2002 23:44:52 -0800 (PST) From: Chatchawan Wongsiriprasert <cws-freebsd-stable@hotel-accommodation.net> To: freebsd-stable@freebsd.org Subject: Start deamon by cron - solved Message-ID: <20021207074452.6899843EA9@mx1.FreeBSD.org>
index | next in thread | raw e-mail
From my question about starting mysql server by cron,I got
a lot of suggestions which are very useful , Thank you for all suggesstions.
Finally, after run cron with debug flags and take a look at cron source code,
I found that the problem is that mysql daemon does not close output pipes and
the following script ,I run from cron, does not force pipes to be closed .
#!/bin/sh
/usr/local/etc/rc.d/mysql-server.sh stop
echo "Start at `date`"
/usr/local/etc/rc.d/mysql-server.sh start 2>&1 > /dev/null
echo "Stop at `date`"
I solve the problem by writing small C program to close pipes
and call /usr/local/etc/rc.d/mysql-server.sh
#include <stdio.h>
int main(int argc,char* argv[])
{
const char *cmd = "/usr/local/etc/rc.d/mysql-server.sh";
int i;
close(1);
close(2);
fopen("/dev/null","wt");
fopen("/dev/null","wt");
execl(cmd,cmd,"start",0);
perror("Can not execl");
return 1;
}
And change the script to
#!/bin/sh
/usr/local/etc/rc.d/mysql-server.sh stop
echo "Start at `date`"
/home/cws/testcron/start-mysqld
echo "Stop at `date
Now , every thing work as I expect.
Regards,
Chatchawan Wongsiriprasert
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021207074452.6899843EA9>
