【发布时间】:2015-02-08 17:23:09
【问题描述】:
您好,我在控制器中有一个功能:
if (!function_exists("ssh2_connect"))
die("function ssh2_connect doesn't exist");
if (!($con = ssh2_connect("myipadresherenotshowingtoyouguys", 22))) {
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if (!ssh2_auth_password($con, "blablabla", "blablabla!")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
$command = 'ssid "Wentzo test2" hide-ssid';
if (!($stream = ssh2_exec($con, $command))) {
echo "fail: unable to execute command\n";
} else {
$stream2 = ssh2_exec($con, $command_save);
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream, 4096)) {
$data .= $buf;
}
fclose($stream);
}
}
}
我想在按下提交按钮时将此脚本作为 cronjob 运行。 但我不知道如何在 symfony 2 中做到这一点。
有人有解决方案吗? 可能是例子?
【问题讨论】:
-
cronjob 是什么意思?您是要运行异步脚本还是要在特定时间连续运行脚本?
-
假设你想异步运行这个脚本,你应该看看这个symfony.com/doc/current/components/process.html
-
感谢您的回答。 Process 组件看起来很有趣!我可以为每个执行的命令设置一个计时器吗?