[英]Google Compute Engine DEBIAN : /etc/group setting lost after Reboot
[英]Setting up a cronjob on Google Compute Engine
我是設置 cronjobs 的新手,我正在嘗試在谷歌計算引擎的虛擬機上進行設置。 經過一番研究,我發現了這個 StackOverflow 問題: Running Python script at Regular interval using Cron in Virtual Machine (Google Cloud Platform)
根據答案,我設法進入crontab -e
編輯模式並設置了一個測試 cronjob,例如10 8 * * * /usr/bin/python /scripts/kite-data-pull/dataPull.py
。 我還檢查了系統時間,它是UTC,並據此輸入時間。
根據答案,我應該采取的步驟是運行sudo systemctl restart cron
這對我來說是一個錯誤:
sudo systemctl restart cron
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
關於我可以做些什么來正確設置這個 cronjob 有什么建議嗎?
使用crontab -e
編輯 cron 作業並插入一行:
* * * * * echo test123 > /your_homedir_path/file.log
這將每分鍾將 test123 寫入test123
文件。
然后執行tail if
並等待幾分鍾。 您應該會看到文件(和屏幕)中出現test123
行。
如果它運行,請嘗試運行您的 python 文件,但首先使用“ chmod +x script.py
”使 your.py 文件可執行
在這里你可以找到我對類似問題的回復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.