Re: how to run another file inside current file?

2013-05-18 Thread fjct...@gmail.com
subprocess?



发自我的小米手机

Avnesh Shakya 编写:

>hi,
>   I want to run a another file inside a ached.add_cron_job(..). how is it 
> possible, please help me, I have a file otherFile.py for execution inside 
> current file.
>I know it is very easy question but i m unable to get anything, please help me.
>example --
>
>import otherFile
>from apscheduler.scheduler import Scheduler
>sched = Scheduler()
>sched.start()
>
>def job_function():
># Can I here add that file for execution, Or can i add that file directly 
> inside cron?
>   
>sched.add_cron_job(job_function, month='1-12', day='1-31', 
>hour='0-23',minute='44-49')
>-- 
>http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python script is not running

2013-05-18 Thread fjct...@gmail.com
make sure data.json is absolute path
make sure you test it directly without crontab 
in the crontab, execute the script in such way, python scripty > /tmp/log 2>&1 
check the log 



发自我的小米手机

Avnesh Shakya 编写:

>hi,
>i want to run python script which generating data into json fromat, I am 
> using crontab, but it's not executing...
>my python code--
>try.py --
>
>import json
>import simplejson as json
>import sys
>
>def tryJson():
>saved = sys.stdout
>correctFile = file('data.json', 'a+')
>sys.stdout = correctFile
>result = []
>i = 1
>for i in range(5):
>info = {
>'a': i+1,
>'b': i+2,
>'c': i+3,
>   }
>result.append(info)
>
>if result:
>print json.dumps(result, indent=6)
>sys.stdout = saved
>correctFile.close()
>tryJson()
>
>now i m doing ion terminal-
>avin@hp:~$ crontab -e
>then type -
>*/2 * * * * python /home/avin/data/try.py
>
>and save
>
>but it's not executing.
>-- 
>http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list