was: Re: how to autorun script at startup as administrator? but now a new problem

Ken D'Ambrosio ken at jots.org
Mon Dec 30 23:53:06 UTC 2019


On 2019-12-22 19:05, Dave Stevens wrote:
> Thanks to all who helped.
> 
> I thought I'd start off slowly because I have not needed to use cron
> explicitly before, so I made a crontab entry that would run a simple
> bash command at ten past the hour. Like this:
> 
> <snip>
> 
> # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
> #
> # For more information see the manual pages of crontab(5) and cron(8)
> #
> # m h  dom mon dow   command
> 
> 40 * * * * /bin/dmesg
> 
> thinking I'd be sure to notice 60k characters scrolling across the
> terminal. But no, the hd lamp blinks and syslog shows lines like this
> at the relevant time:

That doesn't do what you think it does. ;-)  The output of dmesg is 
going to wherever the STDOUT is going for a cronjob -- usually mail.  
Since you don't have mail, though, it's almost certainly getting stashed 
in /var/spool/mail/root/

> Dec 22 15:40:01 dave-900X1B CRON[3715]: (dave) CMD (/bin/dmesg)
> Dec 22 15:40:01 dave-900X1B cron[875]: Please install an MTA on this
> system if you want to use sendmail!
> Dec 22 15:40:01 dave-900X1B CRON[3714]: (dave) MAIL (mailed 60360 bytes
> of output but got status 0x00ff from MTA#012)
> 
> I don't in fact have or want a MTA but have no idea why I
> don't get the desired output or wtf about email??

Output goes where output goes.  If you really *want* the output of dmesg 
to go to the primary console, then tell it do do it:
40 * * * * /bin/dmesg > /dev/tty1

Note that doing that will completely mess up the screen if you're logged 
in on that console; a ^L will usually fix that, depending on which 
application you're in. etc.

As for e-mail, that's what cron does with any unhandled output from a 
cron job.  I'm confused about your two sentences, though: first you say 
you don't have or want an MTA, and *right after* say "wtf about email??" 
  I don't know: what *about* e-mail?  If you're not handling output from 
cron, cron will try to send e-mail.  And it requires an MTA for that.  
Pretty simple, here.

-Ken




More information about the ubuntu-users mailing list