views:

57

answers:

3

when i try to use cron to execute my python script in a future time,i found there is a command at,AFAIK,the cron is for periodly execute,but what my scenario is only execute for once in specificed time. and my question is how to add python script to at command, also it there some python package for control the at command

my dev os is ubuntu 10.04 lucid,and my product server is ubuntu-server 10.04 lucid version. in fact,i want through python script add python script tasks to at command,which file's change can effect at command add or remove new jobs

+2  A: 

type man at, it will explain how to use it. Usage will slighty differ from system to system, so there's no use to tell you here exactly.

knitti
A: 

This works on my linux box:

echo python myscript | at 10:15

Edit: stupid quoting...

bstpierre
A: 

Just do

python FILE | at TIME > app.log

replace: FILE - Your .py file (include the shebang)

TIME - Your time

Zimm3r
i do what you give,it response me a warning,what's the hell?python /home/mlzboy/my/ide/test/c.py | at now+2 minutes >/home/mlzboy/haha.txtwarning: commands will be executed using /bin/shjob 6 at Thu Sep 23 10:27:00 2010
mlzboy
@mizboy do you have the shebang, it seems to me that the terminal thinks what you are running is a batch script, either that or it is referring to it running the command as a batch script (in which case it is bash so that is fine)
Zimm3r
@Zimm3r i had add 1 #!/usr/bin/env python 2 #encoding=utf-8 at top of my py script
mlzboy
@Zimm3ryet i have another relevent question how can i catch the pid of at command currently execute task to write to a file
mlzboy