Louis
Louis

Reputation: 2890

How can I know that a cron job has started or finished?

I have put a long running python program in a cron job on a server, so that I can turn off my computer without interrupting the job. Now I would like to know if the job is correctly started, if it has finished, if there are reasons to stop at a certain point, and so on. How can I do that ?

Upvotes: 1

Views: 1656

Answers (2)

Paul Dixon
Paul Dixon

Reputation: 300855

You could have it write to a logfile, but as it sounds like this isn't possible, you could probably have cron email you the output of the job, try adding [email protected] to your crontab. You should also find evidence of cron activity in your system logfiles (try grep cron /var/log/* to find likely logs on your system).

If you are using cron simply as a way to run processes after you disconnect from a server, consider using screen:

  • type screen and press return
  • set your script running
  • type Ctrl+A Ctrl+D to detatch from the screen

The process continues running even if you log off. Later on simply

  • screen -r

And you will be will reattached, allowing you to review the script's output

Upvotes: 4

Ed Heal
Ed Heal

Reputation: 60007

Why not get that cron job to have a log file. Also just do a ps before shutdown.

Upvotes: 2

Related Questions