Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an hourly hour-long crontab task running with some mtr (traceroute) output every 10 minutes (that is going to go for over an hour prior to it being emailed back to me), and I want to see the current progress thus far.

On Linux, it can be done by accessing the open fd of the temporary file to which the results of the script are saved.

How can I do this on OpenBSD?

I've tried doing fstat | fgrep -e USER -e cron -e mtr, but couldn't find any temporary files at all.

share|improve this question
    
Whether the cron job runs for one hour and gives the output ? –  pradeepchhetri Jan 19 '13 at 9:59

2 Answers 2

You have to intercept the output (or find out where the temporary file is). Dunno how to do this in *BSD, sorry. But consider that unless that file is unbuffered, you'll get to see output only each time it fills up a buffer (prbably around 4 KiB), which could take quite some time. Is it too costly just to do the comand by hand if you want to take a look of current status?

share|improve this answer

I’ve investigated the source as to how cron handles mailing the output from its jobs:

  • cron(8) sets up stdout and stderr of the running job and pipes it directly into mail(1), not leaving any temporary files. Look in do_command.c around line 411 (1).
  • mail(1) needs to fully ready its stdin, since it needs the headers. It opens a temporary file (usually /tmp/mail-R…), but removes it right away, as not to leave traces. Loøk in collect.c at line 83 (2).

In any case, there seems to be deliberate effort not to leave an interceptible temporary file lying around. If you need (or want) to intercept what’s going on in a long-running cronjob, you have to set up a temporary file yourself.

My suggestion at this point is to e.g. add tee $HOME/cronjob.out to your cronjob, which captures a copy of your job’s output in a safe place.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.