使用 nano 编辑 crontab

joh*_*ith 0 cron nano

我一直无法让 crontab 在启动时执行我的任何脚本。我想知道为什么它不起作用。下面是我尝试使用它的示例,我已尝试提供尽可能多的故障排除信息。

$crontab -l
no crontab for server
$crontab -e
#I scroll down to the bottom of the file and add the line below in
@reboot /usr/bin/teamspeak3-server_linux-amd64/ts3server_minimal_runscript.sh
#I make a carriage return at the bottom of the file
Run Code Online (Sandbox Code Playgroud)

我按 ctrl+o 保存文件(因为它在 nano 中打开),然后按 ctrl+z 退出。我现在发出“crontab -e”来检查内容是否存在。该文件显示出来,只是没有我对它所做的更改。我什至尝试在 crontab 文件中只添加一条注释行,这也没有保存。无论如何,我检查了脚本确实正常工作。

$cd /usr/bin/teamspeak3-server_linux-amd64/
$./ts3server_minimal_runscript.sh
Run Code Online (Sandbox Code Playgroud)

然后它在读取脚本并完美加载脚本时提供大量输出。所以我 ctrl+c 退出应用程序,并检查权限。

$ls -l | grep ts3server_minimal
-rwxr-xr-x 1 server server bla bla bla ts3server_minimal_runscript.sh
Run Code Online (Sandbox Code Playgroud)

所以每个人都可以执行它。无论如何我重新启动,发现应用程序没有启动。为什么?

pet*_*try 7

您必须使用Ctrl+x退出nano并安装新的 crontab。Ctrl+z将停止/发送到后台nano而不安装新的 crontab。见附件截图:

纳米命令栏