Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45504
| Date | 2013-05-18 19:18 +0800 |
|---|---|
| Subject | Re: python script is not running |
| From | "fjctlzy@gmail.com" <fjctlzy@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1799.1368875934.3114.python-list@python.org> (permalink) |
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 <avnesh.nitk@gmail.com>编写:
>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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python script is not running "fjctlzy@gmail.com" <fjctlzy@gmail.com> - 2013-05-18 19:18 +0800
csiph-web