FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Computing
User Name
Password  Lost PW

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-16-2012, 08:05 AM   Postid: 181286
hobbes
Have you hugged a tiger today?
 
hobbes's Avatar

Forum Notability:
1238 pts: A True Crowd-pleaser!
[Post Feedback]
 
Join Date: Mar 2000
Location: Third Sol Planet Posts: Far too many. Oh ok -
Posts: 2,705
Linux hacker q

I would like the ability to remote start/stop ssh on one of my Ubuntu 10.04 systems (non-FQ). I have the following cron PHP script that runs once a minute and checks a URL for whether the services should be started or stopped:
Code:
$url = 'http://...'; // URL where I remote set start/stop

$pid = exec("/usr/bin/pgrep sshd"); // Get PID of sshd if already running
$pid = trim($pid);

if (($f = file_get_contents($url)) && preg_match("/^((?:start|stop))\s*$/", $f, 
$matches)) {
	if (($matches[1] == 'start') && ! ctype_digit($pid)) {
		exec("service ssh start");
	} elseif (($matches[1] == 'stop') && ctype_digit($pid)) {
		exec("service ssh stop");
	}
}
The script works fine when run manually. When cron executes however, I get the following error via email and ssh is not started/stopped:
Code:
exec: 129: start: not found
I found a reference to reinstalling udev and upstart, but still get the same behavior.

I have also tried replacing "service ssh" with "/etc/init.d/ssh".

Any thoughts on what else to try?
hobbes is offline   Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:04 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.