免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3176 | 回复: 9
打印 上一主题 下一主题

[桌面系统] cron执行,但是没有结果? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-06-19 16:01 |只看该作者 |倒序浏览
我使用crontab -e命令增加了两项排程:
  1. 59 15 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python
  2. 59 15 * * * tar zcvf /home/amonest/backup.tar.gz /home/amonest/python
复制代码
备份到/home/amonest目录成功了,备份到/var/backups失败了。

/var/log/cron.log记录到了有执行这两项:
  1. Jun 19 15:59:02 amonest-virtual-machine CRON[5328]: (amonest) CMD (tar zcvf /home/amonest/backup.tar.gz /home/amonest/python)
  2. 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身份运行的吗?

论坛徽章:
0
2 [报告]
发表于 2012-06-19 16:35 |只看该作者
回复 1# amonest


    cron进程不是以root身份运行的吗

    该crontab 任务不再root列表下! 任务里的命令执行权限是普通用户的!

论坛徽章:
0
3 [报告]
发表于 2012-06-19 16:36 |只看该作者
crontab  -l   

论坛徽章:
0
4 [报告]
发表于 2012-06-19 16:50 |只看该作者
  1. # Edit this file to introduce tasks to be run by cron.
  2. #
  3. # Each task to run has to be defined through a single line
  4. # indicating with different fields when the task will be run
  5. # and what command to run for the task
  6. #
  7. # To define the time you can provide concrete values for
  8. # minute (m), hour (h), day of month (dom), month (mon),
  9. # and day of week (dow) or use '*' in these fields (for 'any').#
  10. # Notice that tasks will be started based on the cron's system
  11. # daemon's notion of time and timezones.
  12. #
  13. # Output of the crontab jobs (including errors) is sent through
  14. # email to the user the crontab file belongs to (unless redirected).
  15. #
  16. # For example, you can run a backup of all your user accounts
  17. # at 5 a.m every week with:
  18. # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  19. #
  20. # For more information see the manual pages of crontab(5) and cron(8)
  21. #
  22. # m h  dom mon dow   command

  23. 12 16 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python
  24. 12 16 * * * tar zcvf /home/amonest/backup.tar.gz /home/amonest/python
复制代码

论坛徽章:
0
5 [报告]
发表于 2012-06-19 16:51 |只看该作者
回复 2# taojie2000

能修改成root吗?


   

论坛徽章:
0
6 [报告]
发表于 2012-06-19 17:11 |只看该作者
回复 5# amonest


    你会用 命令切换到root 用户不

    然后root用户下添加

论坛徽章:
0
7 [报告]
发表于 2012-06-19 17:15 |只看该作者
sudo crontab -u root -e?

taojie2000 发表于 2012-06-19 17:11
回复 5# amonest

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
8 [报告]
发表于 2012-06-19 19:46 |只看该作者
su - root
crontab -e

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
9 [报告]
发表于 2012-06-19 21:44 |只看该作者
或者也可以直接将 /var/backups 目录权限改成你当前用户可读写的权限。

论坛徽章:
0
10 [报告]
发表于 2012-06-26 02:30 |只看该作者
權限問題,可用以下方法確認
另外,一般用户都可以設定cron

12 16 * * * tar zcvf /var/backups/home.tar.gz /home/amonest/python > /tmp/varbackup.log 2>&1
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP