From owner-freebsd-stable Fri Dec 6 23:45: 8 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8199D37B401 for ; Fri, 6 Dec 2002 23:45:06 -0800 (PST) Received: from www.hotel-accommodation.net (pool-wnet-30-38.pacific.net.th [203.152.30.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6899843EA9 for ; Fri, 6 Dec 2002 23:44:52 -0800 (PST) (envelope-from cws-freebsd-statble@hotel-accommodation.net) From: Chatchawan Wongsiriprasert To: freebsd-stable@freebsd.org Subject: Start deamon by cron - solved Message-Id: <20021207074452.6899843EA9@mx1.FreeBSD.org> Date: Fri, 6 Dec 2002 23:44:52 -0800 (PST) Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 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