Michael Yang wrote:
thanks. so this would run my script on a schedule i specify. And its a "set it and forget it" deal.

but if i want to view the output of the program (ie. the program has various print statements to show program's status), how would I do this while its running the job?

MIke

On Thu, Sep 3, 2009 at 2:45 AM, Christian Witts <cwi...@compuscan.co.za <mailto:cwi...@compuscan.co.za>> wrote:

    Michael Yang wrote:

        Hi Everyone,

        I'm new to programming and to python.
        I have a program I want to run on my Media Temple Virtual
        Server (dv) - Linux. which has the latest Plesk 9 virtuozzo
        installed.

        Ultimately I want it to run the program (main.py) on a
        scheduled basis.  How do I do this?



        Thanks!

        -Mike
        ------------------------------------------------------------------------



        _______________________________________________
        Tutor maillist  -  Tutor@python.org <mailto:Tutor@python.org>
        To unsubscribe or change subscription options:
        http://mail.python.org/mailman/listinfo/tutor
    Are you able to run it as a cron job ?  That would be by far the
    easiest solution.

    crontab -e
    syntax when editing is "minute hour dayOfMonth month dayofWeek
    command" so you would do
    0 0-23 * * * python main.py
    which would run your python script every hour every day.
    Personally, if you do schedule it like this you would better off
    calling a shell script with the cron job and in the shell script
    listing certain environment variables you might need and then
    calling the script.  The job won't be running under your normal
    user account so you might need to add them.

-- Kind Regards,
    Christian Witts





--
Thanks,
Michael Yang

917-699-4655 phone
212-500-0553 fax
It is indeed "set and forget". Once your cron job is setup it was always execute the command for you at your scheduled intervals. Another creative way of running it would be to call 'at' at the end of the script to execute it again, for example 'at -f name_of_shell_script.sh now + 30 minutes' which would run it again in 30 minutes for you.

If you change your print statements to write it to a log file instead, or in your shell script use the redirection characters > or >> to push the output to a file you want then you can use "tail -f filename" to watch the log file as output comes through.

--
Kind Regards,
Christian Witts


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to