亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

bash - Crontab 中自動執(zhí)行后沒有生效
過去多啦不再A夢
過去多啦不再A夢 2017-04-24 15:59:00
0
5
981

使用crontab 添加一個定時任務

* * * * /bin/bash -l -c ' ~/.script.sh'

這個腳本的作用是統(tǒng)計一些數(shù)據(jù)并生成報表文件.

這個腳本每分鐘執(zhí)行一次,但是實際操作中crontab并沒有像預期的那樣生成報表文件.

然而當我手動執(zhí)行這個命令時 "~/.script.sh" 生成文件并退出.

有兩個疑問:

1: 為什么crontab 沒有執(zhí)行我的腳本. 查看了crontab 日志(/var/log/crond)輸出: May 5 20:36:01 localhost CROND[27260]: (ernest) CMD (/bin/bash -l -c '~/script.sh') 沒有發(fā)現(xiàn)任何異常.

2: 會不會是我執(zhí)行腳本的環(huán)境 不一樣呢? 測試了一下 "* * * * * /bin/bash -l -c 'source ~/.bash_profile && ~/.script.sh'" 也不行.

各位大牛們有沒有遇到和我一樣的問題呢?

過去多啦不再A夢
過去多啦不再A夢

reply all(5)
過去多啦不再A夢

Manually running the script takes effect, but the most common reasons why crontab does not take effect are: The commands in your script do not use absolute paths.

習慣沉默

Try using absolute path. Because~對不同的用戶會解釋成不同的$HOME.
Usually add script.sh at the beginning of

cd /home/username
. .profile
PHPzhong

If you create the crontab command with sudo crontab -e, then the executing user is root, and the ~ here will also be parsed as /root If you're not using sudo, that should be fine.

左手右手慢動作
* * * * /bin/bash -l -c ' ~/.script.sh'

這個時間設置錯了呀。
Ty80

Could it be a file permission issue?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template