5

I am automatically running a simple python program from start up using cron. The pi boots / automatically logs in, displays the command line and runs the python program but the print output (updating count) is not displayed.

The print output works fine if I run the program via idle (ie having enabled LXDE) and it also works fine if (without running the LXDE desktop) I manually run the program from the command line, e.g. sudo python pimon.py

What is needed to see the print output when I start the program using cron? I do not want to have to enable the LXDE desktop first.

The crontab entry is: @reboot python /home/pi/Python27/pimon.py

Ghanima
  • 15,958
  • 17
  • 65
  • 125
DONALD
  • 51
  • 1
  • 1
  • 2

1 Answers1

4

As others have noted in the comments, you need to redirect the output from the command somewhere.

This will write to a file, overwriting the file if it already exists.

@reboot python /home/pi/Python27/pimon.py > /path/to/output_file.txt

Change > to >> if you want to append to an existing file.

Check this link for more information on standard input and output redirection.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
mazianni
  • 231
  • 1
  • 6