我需要定期运行Bash文件,它必须是root用户.
那可能吗?
[root@file nutch-0.9]# locate crontab
/etc/crontab
/etc/sysconfig/crontab
/usr/bin/crontab
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man1p/crontab.1p.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/vim/vim71/syntax/crontab.vim
[root@file nutch-0.9]#
Run Code Online (Sandbox Code Playgroud)
只需指定root该条目的用户/etc/crontab:
0 0 * * * root somecommand
Run Code Online (Sandbox Code Playgroud)
或者,您也可以使用crontab -eroot用户将命令添加到root的个人crontab中.
小智 5
无论如何,您将需要有权访问root用户帐户。
我的建议?使用root crontab。这就是它的用途。
此外,sth建议在crontab中没有用户输入...语法为:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
Run Code Online (Sandbox Code Playgroud)
如果要在crontab中以root身份输入某些内容,只需登录到root帐户“ crontab -e”,然后瞧瞧... root crontab。
| 归档时间: |
|
| 查看次数: |
58432 次 |
| 最近记录: |