Chinaunix
标题:
cron执行,但是没有结果?
[打印本页]
作者:
amonest
时间:
2012-06-19 16:01
标题:
cron执行,但是没有结果?
我使用crontab -e命令增加了两项排程:
59 15 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python
59 15 * * * tar zcvf /home/amonest/backup.tar.gz /home/amonest/python
复制代码
备份到/home/amonest目录成功了,备份到/var/backups失败了。
/var/log/cron.log记录到了有执行这两项:
Jun 19 15:59:02 amonest-virtual-machine CRON[5328]: (amonest) CMD (tar zcvf /home/amonest/backup.tar.gz /home/amonest/python)
Jun 19 15:59:02 amonest-virtual-machine CRON[5329]: (amonest) CMD (tar zcvf /var/backups/home.tar.gz /home/amonest/python)
复制代码
是权限问题导致备份/var/backups不成功吗?cron进程不是以root身份运行的吗?
作者:
taojie2000
时间:
2012-06-19 16:35
回复
1#
amonest
cron进程不是以root身份运行的吗
该crontab 任务不再root列表下! 任务里的命令执行权限是普通用户的!
作者:
taojie2000
时间:
2012-06-19 16:36
crontab -l
作者:
amonest
时间:
2012-06-19 16:50
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
12 16 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python
12 16 * * * tar zcvf /home/amonest/backup.tar.gz /home/amonest/python
复制代码
作者:
amonest
时间:
2012-06-19 16:51
回复
2#
taojie2000
能修改成root吗?
作者:
taojie2000
时间:
2012-06-19 17:11
回复
5#
amonest
你会用 命令切换到root 用户不
然后root用户下添加
作者:
amonest
时间:
2012-06-19 17:15
sudo crontab -u root -e?
taojie2000 发表于 2012-06-19 17:11
回复 5# amonest
作者:
Shell_HAT
时间:
2012-06-19 19:46
su - root
crontab -e
作者:
snow888
时间:
2012-06-19 21:44
或者也可以直接将 /var/backups 目录权限改成你当前用户可读写的权限。
作者:
ccxxx
时间:
2012-06-26 02:30
權限問題,可用以下方法確認
另外,一般用户都可以設定cron
12 16 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python > /tmp/varbackup.log 2>&1
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2