私の問題は、cronjob は正常に実行されているように見えますが、.sh ファイル内でコードが適切に実行されていないことです。詳細については、以下を参照してください。
crontab -e と入力して、cron を起動します。そのファイルで:
30 08 * * 1-5 /home/user/path/backup.sh
45 08 * * 1-5 /home/user/path/runscript.sh >> /home/user/cronlog.log 2>&1
バックアップ.sh:
#!/bin/sh
if [ -e "NEW_BACKUP.sql.gz" ]
then
mv "NEW_BACKUP.sql.gz" "OLD_BACKUP.sql.gz"
fi
mysqldump -u username -ppassword db --max_allowed_packet=99M | gzip -9c > NEW_BACKUP.sql.gz
runscript.sh:
#!/bin/sh
python /home/user/path/uber_sync.py
uber_sync.py:
import keyword_sync
import target_milestone_sync
print "Starting Sync"
keyword_sync.sync()
print "Keyword Synced"
target_milestone_sync.sync()
print "Milestone Synced"
print "Finished Sync"
問題は、uber_sync で print ステートメントを実行しているように見えますが、実際には import ステートメントからコードを実行しないことです...何かアイデアはありますか?
また、keyword_sync と target_milestone_sync は uber_sync と同じディレクトリ、つまり /home/user/path にあることに注意してください。
助けてくれてありがとう。