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

Re: MY crontab ain't me!



On Mon, Dec 21, 2020 at 08:42:26AM -0500, Gene Heskett wrote:
> I got an email from cron this morning that needs some explaining.
> Here is a dcop connand _I_ can execute, no error
> /opt/trinity/bin/dcop kmail KMailIface resumeBackgroundJobs
> 
> But I put it in MY crontab and get this email
> 
> Cron <gene@coyote> /opt/trinity/bin/dcop kmail KMailIface 
> resumeBackgroundJobs
>  From: Cron Daemon <root@coyote.coyote.den>
>  To: gene@coyote.coyote.den
>  
> ERROR: Couldn't attach to DCOP server!
> 
> I have other scripts to aid my incoming email that run as me, and use 
> dcop to get their job done w/o a problem.
> 
> But put the exact same command in MY crontab and its rejected.

This is, as I gather, your "personal" crontab. So the cron job
is running under you UID. Good.

> 2 questions, why?, and why is this email from root?

As to your first question, the most probable cause is that your
cron job hasn't the environment needed to get in touch with
the DCOP server.

One typical mechanism (note that I know zilch about DCOP, and,
to be honest, would like to avoid dirtying my soul with all
the saddening details ;-) is that DCOP listens on some socket.
Typically (again), there is an environment variable (or several)
in your session's environment containing the coordinates of
said socket (or - whatever).

What you can do is (besides reading DCOP's documentation, if
any) issue

  set | grep DCOP

(or some variation on it) to find about likely environment
variable candidates. This, of course, from a shell running
under your DE's environment (a terminal window started from
your GUI will do).

Then set those environment variables in your cron job. The
crontab format itself (cf. man 5 crontab) has provisions to
set environment -- alternatively you can call from there a
script setting the necessary environment (perhaps because
you don't want all your cron entries to have the same
environment).

Possibly DCOP has some utility to "join" a user "session",
dunno.

But this all is a hunch. Some tinkering needed.

I test out such things by letting my cron commands append
debugging stuff to some temporary file. By default, cron
has no logfiles and mails you its complaints, as you
already found out.

As to your second question -- cron runs as root and changes
to the relevant UID when needed (it couldn't were it not
root).

Attachment: signature.asc
Description: Digital signature


Reply to: