[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: running cronjob output



On Wed 21 Apr 2021 at 00:37:25 (+0000), brainfart@posteo.net wrote:
> On 2021-04-20 12:14 PM, l0f4r0@tuta.io wrote:
> > > On Tue, Apr 20, 2021 at 12:54:06PM +0000, brainfart@posteo.net wrote:
> > > 
> > > > when i run a cronjob the output from the job is stored and
> > > > mailed when the
> > > > job finishes. where is this output stored? can i read it
> > > > while the job is
> > > > running?
> > > > 
> > Is your question global or specific?
> 
> for any cronjob

Almost the entire answer is given at:

https://unix.stackexchange.com/questions/40623/where-does-the-output-of-at-and-cron-jobs-go

ie find the PID of your long-running cron job: it should be
a child of the daemon and the parent of your program. When you:

# ls -l /proc/<PID>/fd/

you should see one output file descriptor pointing to a
(deleted) file. So the answer to the last question is:

# cp -Lip /proc/16098/fd/6 /tmp/proc16098fd6.txt

for example, where 16098 is the cron job, 6 is the
name of the symlink pointing to a (deleted) file,
and -L makes copy follow the symlink.

This method has the advantage that it can be used after
the cron job has already started, but I would use the
"tee" method, previously described in this thread, if
you think you might want to examine the output while
you're still preparing your crontab file for installation.

Cheers,
David.


Reply to: