View Full Version : How to Stop and Restart Service
effe
8th November 2005, 09:19 PM
Hi all,
for stop and restart one service is possible use a cron daemon?
i have try to configure a cron.daily but script don't find a command for stopping vmware service.
I think that cron.daily don't find a PATH. :confused:
Subject: Cron <root@test> cd /sbin/service vmware stop
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
/bin/sh: line 0: /sbin/service: Not a directory
how I can make a backup for my virtual machine?
thanxs
ahz2
9th November 2005, 12:49 AM
take out "cd" before "/sbin"
effe
9th November 2005, 04:53 PM
Subject: Cron <root@test> cd /sbin/service vmware stop
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
how can i change this parameter?
X-Cron-Env: <PATH=/usr/bin:/bin>
effe
ahz2
9th November 2005, 05:05 PM
1. Run crontab -e
2. At the beginning of the file type
PATH=/foo:/blah
But I doubt the path is the problem. The real problem seems to be a spurious "cd" before "/sbin/service"
effe
9th November 2005, 08:33 PM
nothing to do....
Subject: Cron <root@Xsrv> cd /sbin/service vmware stop
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
/bin/sh: line 0: cd: /sbin/service: Not a directory
i have made this change in crontab:
0 22 * * * cd /sbin/service vmware stop
0 4 * * * cd /sbin/service vmware start
do you have any ideas?
thanx effe
ilja
9th November 2005, 08:35 PM
Don't use cd ! Not
0 22 * * * cd /sbin/service vmware stop
but
0 22 * * * /sbin/service vmware stop
cd means change directory!
effe
9th November 2005, 08:40 PM
ok ok
i have fixed my problem..... thank you....
[root@Xsrv ~]# vi /var/spool/mail/root
by Xsrv.local.net (8.13.4/8.13.4/Submit) id jA9L02xF004538;
Wed, 9 Nov 2005 22:00:02 +0100
Date: Wed, 9 Nov 2005 22:00:02 +0100
Message-Id: <200511092100.jA9L02xF004538@Xsrv.local.net>
From: root@Xsrv.local.net (Cron Daemon)
To: root@Xsrv.local.net
Subject: Cron <root@Xsrv> /sbin/service vmware stop
X-Cron-Env: <PATH=/foo:/blah>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Stopping VMware services:
Virtual machine monitor[ OK ]
Bridged networking on /dev/vmnet0[ OK ]
DHCP server on /dev/vmnet1[ OK ]
Host-only networking on /dev/vmnet1[ OK ]
DHCP server on /dev/vmnet8[ OK ]
NAT service on /dev/vmnet8[ OK ]
Host-only networking on /dev/vmnet8[ OK ]
Virtual ethernet[ OK ]
My crontab
PATH=/foo:/blah
0 22 * * * /sbin/service vmware stop
0 4 * * * /sbin/service vmware start
ilja
9th November 2005, 08:41 PM
PATH=/foo:/blah
http://en.wikipedia.org/wiki/Foo :D and http://www.ietf.org/rfc/rfc3092.txt
ahz2
9th November 2005, 08:45 PM
Great, now I have to make sure all my usage of foo confirms to RFC. :rolleyes:
effe: "foo" means whatever you want, so you can use whichever path name you want in place of foo. Just list directory names with a colon in between, and start with PATH=. You are simply setting the environment variable a string delimited by colons.
PATH=/usr:/usr/bin:/sbin/usr/sbin
Now that you removed the bad cd, you may want to remove PATH. I think the cd was the problem, not PATH.
effe
9th November 2005, 09:11 PM
ahz2, i have tried to do..but noting.... if you see here
Subject: Cron <root@Xsrv> cd /sbin/service vmware stop
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
/bin/sh: line 0: cd: /sbin/service: Not a directory
the task interpreter think that /sbin/service is a directory....
thank you for your help and please me for a bad english!
effe
ahz2
9th November 2005, 09:16 PM
remove cd from before /sbin/service
remove cd from before /sbin/service
effe
9th November 2005, 09:27 PM
ok stop....
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.