操作系統:Debian JessieDebian systemd服務在網絡準備就緒之前啓動
我想在每次系統啓動時更新用戶文件夾中的git存儲庫。
我試着用cron @reboot入口。克朗開始過早,並在結果郵寄給我「SSH:無法解析主機名...」
然後,我嘗試了SysV初始化腳本。效果 - 相同。
目前我正在嘗試systemd服務與相同的錯誤報告。
在/ usr/bin中/ git_repo
#! /bin/sh
# Description: Updates local git repository with latest content
#cd /home/tanglor/repo
su -c'cd repo;git pull' - tanglor
/etc/systemd/system/repo.service
[Unit]
Description = Updates local git repository with latest content
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/repo
[Install]
WantedBy=multi-user.target
仍然沒有結果。我的意思是在系統日誌中,我發現:
Sep 30 19:41:59 Khlavan repo[422]: ssh: Could not resolve hostname bitbucket.org: Name or service not known
Sep 30 19:41:59 Khlavan repo[422]: fatal: Could not read from remote repository.
Sep 30 19:41:59 Khlavan repo[422]: Please make sure you have the correct access rights
Sep 30 19:41:59 Khlavan repo[422]: and the repository exists.
Sep 30 19:41:59 Khlavan systemd[1]: repo.service: main process exited, code=exited, status=1/FAILURE
Sep 30 19:41:59 Khlavan systemd[1]: Failed to start Updates local git repository with latest content.
Sep 30 19:41:59 Khlavan systemd[1]: Unit repo.service entered failed state.
如何在每個系統啓動時實現存儲庫更新?
一個解決方案是使用帶有睡眠命令的腳本,它將等待一些ssh測試成功並完成。但這是最後的手段,我想通過這本書解決。
這太瘋狂了。如果你不經常重新啓動會怎樣? – tripleee
'一個解決方案是使用帶有sleep命令的腳本,它將等待一些ssh測試成功並完成。 「這是迄今爲止我發現的唯一可靠解決方案。 Systemd很奇怪。 – Mahn