Ngo Thanh Nhan
Ngo Thanh Nhan

Reputation: 513

How to view stdout of a running python started by crontab

I have a running python program (on Amazon linux server). This program was started by crontab.

How can I view its content stdout without stopping it?

Upvotes: 0

Views: 481

Answers (2)

Oliver Baumann
Oliver Baumann

Reputation: 2289

Elaborating on Loïc's answer:

The "1" at the end of tail -f /proc/28897/fd/1 denotes the stream you want to look into. 0 is STDIN, 1 is STDOUT, 2 is STDERR (https://en.wikipedia.org/wiki/File_descriptor)

Adding this as it can be quite cryptic to understand the black magic behind FDs, and as I don't have enough rep to comment ;-)

Upvotes: 2

Loïc
Loïc

Reputation: 11942

You could just read the proc filesystem :

tail -f /proc/28897/fd/1

28897 is the process id.

You can get the process id using ps

For instance : ps aux | grep myScript.py

Upvotes: 3

Related Questions