Cron
用於啟動無 IP 的 Crontab 不起作用
我的網路伺服器有問題。通常,您通過 啟動 No-IP-DUC
sudo noip2
。我嘗試使用 cronjob 將其自動化。使用crontab -e
,我創建了這個文件:# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command @reboot cd /home/username/noip-2.1.9-1 && sudo noip2
它不起作用,我不知道為什麼。如果有人可以幫助我,那就太好了。
我找到了另一種解決方案:我將路由器連接到 No-IP,它現在可以工作了。
而不是做
cd /home/username/noip-2.1.9-1 && sudo noip2
我寧願執行“sudo crontab -e”以將 cronjob 添加為 root(並避免在 cronjob 中執行 sudo)。
另外,我了解您要執行 noip2 (即在 /home/username/noip-2.1.9-1 文件夾內)。所以我會將 cronjob 更改為
@reboot /home/username/noip-2.1.9-1/noip2