[Tutor] Collecting output from Python scripts executed via Cron

Leo Silver leo.silver at soholinux.com.au
Sat May 20 09:31:22 EDT 2017


Thanks, I'll give this ago and explore the full logging option if I need
more control.
Regards, Leo.

On 20 May 2017 at 20:04, Cameron Simpson <cs at zip.com.au> wrote:

> On 19May2017 11:48, Leo Silver <leo.silver at soholinux.com.au> wrote:
>
>> I have written a several Python scripts to collect data from external
>> sources (an email account and an sftp site).
>>
>> In development I run the scripts from IDLE or the command line and can
>> view
>> the output of various print statements in the scripts which helps me to
>> monitor progress and confirm correct operation.
>>
>> However, in production I will be running the scripts via Cron.
>>
>> Is there a recommended/ elegant way to collect this output on the fly for
>> later review/ processing.
>>
>> Previously I have written bash scripts simply redirecting the standard
>> output to a text file and emailed this back to myself but I would like to
>> do this directly within Python rather than having to wrap the Python
>> script
>> in a bash script.
>>
>
> You know that cron jobs _are_ shell commands?
>
> Is there anything wrong with either:
>
>  ..... your-program.py | mail -s subject-line you at example.com
>
> Or, if you're using Vixie cron (very very common), set MAILTO in your
> crontab and let cron do the work:
>
>  MAILTO=you at example.com
>  ....... your-program.py
>
> Obviously "......." is your cron schedule values.
>
> Cheers,
> Cameron Simpson <cs at zip.com.au>
>


More information about the Tutor mailing list