Chinaunix首页 | 论坛 | 博客
  • 博客访问: 536367
  • 博文数量: 84
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 2109
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-25 14:02
文章分类

全部博文(84)

文章存档

2011年(10)

2010年(22)

2009年(16)

2008年(36)

我的朋友

分类: LINUX

2009-04-09 08:58:03

I figured out how to create a crontab entry from within python, by simply running the bash command (echo '...' | crontab e) with the os.system module, and also how to remove again (crontab -r).
The only problem is that crontab -r purges the whole crontab-user-file, and I have not found a way to only remove the desired crontab-entry.

Any suggestions?

I'm looking for a hint in the gnome-schedule source, but until then, it would be cool if some of ya' could point me in the right direction.

UPDATE
I didn't get much out of gnome-schedule, but I found a way of using crontab -l to do the thing.
First you pipe crontab -l in a file, then you do the changes on the file, and then you pipe the changed file back via crontab -.
It works really great!
__________________

Okay, so I figured out than what I need, was to specify the display environment for the crontab.

Code:
*/2 * * * * DISPLAY=:0.0 /home/cb/Documents/Projects/gnotify/gn.py
I also discovered that it only needed to have chmod +x, and not everything else like adding crontab to its permissions group and that stuff.

UPDATE
But I'm still looking for some enlightenment on how to add/remove crontabs from the python app.
__________________
Chris Buchholz

阅读(604) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~