启动的文件手动运行,但不会自动运行 [英] launchd file runs manually but not automatically
问题描述
我已经编写了一个plist文件并将其放入/Library/LaunchDaemons
I have written a plist file and placed it into /Library/LaunchDaemons
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList- 1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dotcafe.DCDMySQLBackup</string>
<key>ProgramArguments</key>
<array>
<string>/Users/robdando/Webserverbackup/grab.sh</string>
</array>
<key>StartInterval</key>
<integer>900</integer>
</dict>
</plist>
我现在已经从终端手动获取了脚本文件,但是我似乎无法按要求每15分钟运行一次该脚本,它调用的脚本登录到ftp服务器上并拉下mysql数据库的备份.
I have now got the script to file from terminal manually but I cannot seem to get it to run every 15 mins as I require, the script it calls logs onto an ftp server and pulls down a backup of mysql databases.
提前加油.
推荐答案
您是否已将作业加载到正确的launchd
中?根据放置文件的位置,看起来应该执行sudo launchctl load /Library/LaunchDaemons/com.dotcafe.DCDMySQLBackup.plist
.之后,您可以sudo launchctl start com.dotcafe.DCDMySQLBackup
吗?
Have you loaded the job into the correct launchd
? Based on where you placed the file, it looks like you should be doing sudo launchctl load /Library/LaunchDaemons/com.dotcafe.DCDMySQLBackup.plist
. Afterwards, can you sudo launchctl start com.dotcafe.DCDMySQLBackup
?
即使基于日历的launchd
作业在我按launchctl start
加载并正常工作时也没有运行,却遇到了问题.我试图以用户身份每天运行该作业,所以我的解决方案是将其转换为cron
作业.
I have had problems with a calendar-based launchd
job not running when it should, even though it was loaded and worked fine when I launchctl start
ed it. I was trying to run the job daily as my user, so my solution was to just turn it into a cron
job.
这篇关于启动的文件手动运行,但不会自动运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!