我正试图找到一种好的方式来跟踪远程主机上的文件。这是在Linux机器的内部网络上。所需经费如下:
我尝试过的解决方案一般都是这样的。
ssh remotemachine -f <some command>“某些命令”是:
tail -f logfile基本尾不工作,因为远程进程在本地ssh进程死后继续向终端写入输出。
$socket = IO:Socket::INET->new(...);
$pid = fork();
if(!$pid)
{
exec("ssh $host -f '<script which connects to socket and writes>'");
exit;
}
$client = $socket->accept;
while(<$client>)
{
print $_;
}这样做更好,因为在本地进程退出后,屏幕上没有输出,但是远程进程没有发现它的套接字已关闭,并且它无限期地继续存在。
发布于 2009-02-19 17:05:16
你试过吗
ssh -t remotemachine <some command>来自ssh手册页的-t选项:
-t Force pseudo-tty allocation. This can be used to execute
arbitrary screen-based programs on a remote machine, which
can be very useful, e.g. when implementing menu services.
Multiple -t options force tty allocation, even if ssh has no local tty.而不是
-f Requests ssh to go to background just before command execution.
This is useful if ssh is going to ask for passwords or passphrases,
but the user wants it in the background.
This implies -n. The recommended way to start X11 programs at a remote
site is with something like ssh -f host xterm.发布于 2009-02-19 16:38:33
一些想法:
tail -f。发布于 2010-02-20 22:44:20
不过,您只可以尝试Survlog它的OS。
https://stackoverflow.com/questions/566110
复制相似问题