Unix Technical Forum

running emerge --sync in cron

This is a discussion on running emerge --sync in cron within the Gentoo Linux Support forums, part of the Unix Operating Systems category; --> I wanted to know if I run emerge --sync as a cron job, do I need to redirect output? ...


Go Back   Unix Technical Forum > Unix Operating Systems > Gentoo Linux Support

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2008, 11:03 AM
Peter
 
Posts: n/a
Default running emerge --sync in cron

I wanted to know if I run emerge --sync as a cron job, do I need to
redirect output? a la

emerge --sync >/dev/null 2>&1

Or will output be suppressed automatically?
On this page,http://www.gentoo.org/doc/en/cron-guide.xml

Code Listing 3.17: A real crontab

22 2 * * 1 /usr/bin/updatedb
30 6 * * * /usr/bin/emerge --sync
(if you're using anacron, add this line)
30 7 * * * /usr/sbin/anacron -s

The output redirection is absent. Will this work?

Using:
sys-process/cronbase-0.3.2
sys-process/vixie-cron-4.1-r8

TIA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-21-2008, 11:03 AM
J.O. Aho
 
Posts: n/a
Default Re: running emerge --sync in cron

Peter wrote:
> I wanted to know if I run emerge --sync as a cron job, do I need to
> redirect output? a la
>
> emerge --sync >/dev/null 2>&1
>
> Or will output be suppressed automatically?


The output will be mailed to root if it's not redirected somewhere else.

> On this page,http://www.gentoo.org/doc/en/cron-guide.xml
>
> Code Listing 3.17: A real crontab
>
> 22 2 * * 1 /usr/bin/updatedb
> 30 6 * * * /usr/bin/emerge --sync
> (if you're using anacron, add this line)
> 30 7 * * * /usr/sbin/anacron -s
>
> The output redirection is absent. Will this work?
>
> Using:
> sys-process/cronbase-0.3.2
> sys-process/vixie-cron-4.1-r8


It won't prevent from working, just that extra email each day.


//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-21-2008, 11:03 AM
oKtosiTe
 
Posts: n/a
Default Re: running emerge --sync in cron

J.O. Aho wrote:
> Peter wrote:
>
>> I wanted to know if I run emerge --sync as a cron job, do I need to
>> redirect output? a la
>>
>> emerge --sync >/dev/null 2>&1
>> Or will output be suppressed automatically?

>
>
> The output will be mailed to root if it's not redirected somewhere else.
>
>> On this page,http://www.gentoo.org/doc/en/cron-guide.xml
>>
>> Code Listing 3.17: A real crontab
>>
>> 22 2 * * 1 /usr/bin/updatedb
>> 30 6 * * * /usr/bin/emerge --sync
>> (if you're using anacron, add this line)
>> 30 7 * * * /usr/sbin/anacron -s
>>
>> The output redirection is absent. Will this work?
>>
>> Using:
>> sys-process/cronbase-0.3.2
>> sys-process/vixie-cron-4.1-r8

>
>
> It won't prevent from working, just that extra email each day.
>
>
> //Aho

Yep, I like that e-mail. I actually wrote a little daily script for this:

[script]
#! /bin/sh

if [ -x /usr/bin/emerge ]
then
/usr/bin/emerge --quiet --sync
/usr/bin/emerge -puNDvt world
fi
[/script]

It's fairly clean because of the "--quiet", and also shows me any available updates.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-21-2008, 11:03 AM
Peter
 
Posts: n/a
Default Re: running emerge --sync in cron

On Sun, 05 Feb 2006 18:15:05 +0100, oKtosiTe wrote:

snip...
> Yep, I like that e-mail. I actually wrote a little daily script for this:
>
> [script]
> #! /bin/sh
>
> if [ -x /usr/bin/emerge ]
> then
> /usr/bin/emerge --quiet --sync
> /usr/bin/emerge -puNDvt world
> fi
> [/script]
>
> It's fairly clean because of the "--quiet", and also shows me any
> available updates.


Ah, thanks both of you. I forgot about the quiet command. Just for
clarification, though. Does cron automatically suppress stdout and stderr?
I see some scripts with >/dev/null from time to time. Is that necessary?

Thanks again!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-21-2008, 11:03 AM
J.O. Aho
 
Posts: n/a
Default Re: running emerge --sync in cron

Peter wrote:

> Ah, thanks both of you. I forgot about the quiet command. Just for
> clarification, though. Does cron automatically suppress stdout and stderr?
> I see some scripts with >/dev/null from time to time. Is that necessary?


Not every function has quiet mode and quiet mode don't necessarily suppress
error messages (can be cases where you don't care if something fails).
And sometimes it can be just to be on the safe side.


//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-21-2008, 11:03 AM
Arthur Hagen
 
Posts: n/a
Default Re: running emerge --sync in cron

Peter <peter@localhost.com> wrote:
>
> Ah, thanks both of you. I forgot about the quiet command. Just for
> clarification, though. Does cron automatically suppress stdout and
> stderr? I see some scripts with >/dev/null from time to time. Is that
> necessary?


Upon completion, cron will send the output of stdout and stderr by email
to the account under which the cron job ran. If there's no output, no
mail will be sent. Since you generally only want warnings, it's common
to suppress informational output (stdout or -q[uiet] options) to avoid
this email, but allow error messages by not redirecting stderr.

Regards,
--
*Art

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-21-2008, 11:03 AM
Peter
 
Posts: n/a
Default Re: running emerge --sync in cron

On Sun, 05 Feb 2006 18:15:05 +0100, oKtosiTe wrote:

snip...
> Yep, I like that e-mail. I actually wrote a little daily script for this:
>
> [script]
> #! /bin/sh
>
> if [ -x /usr/bin/emerge ]
> then
> /usr/bin/emerge --quiet --sync
> /usr/bin/emerge -puNDvt world
> fi
> [/script]
>


I made some small mods to this script. I'd appreciate your comments. TIA
#!/bin/sh

# run emerge sync and emerge -puNDvt world in cron

MAILTO=peter
NICE=/usr/bin/nice
EMERGE=/usr/bin/emerge

if [ -x "$EMERGE" ]
then
$NICE $EMERGE --quiet --sync
$NICE $EMERGE -puNDvt --nospinner world
fi

Basically, adding nice would stop the cpu from going to 99 when updating
the cache or when searching. Not sure if nospinner is needed since
technically, emerge is not being run from a TTY.

For the moment, though, I do not get email. Even after emerging mailx I
still get nothing. Something's wrong with sendmail.

From cron's log:
Feb 6 09:00:06 [cron] (root) MAIL (mailed 1402 bytes of output but got status 0x0001_)

From mail's log:Feb 6
09:00:06 [sSMTP] Unable to locate mail
Feb 6 09:00:06 [sSMTP] Cannot open mail:25

So, for the time being, unless I figure this out, I'll just redirect output
from emerge -p.... to a file in my home dir.

Any ideas why mail bombs?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-21-2008, 11:03 AM
Johan Lindquist
 
Posts: n/a
Default Re: running emerge --sync in cron

So anyway, it was like, 15:31 CET Feb 06 2006, you know? Oh, and, yeah,
Peter was all like, "Dude,

> Basically, adding nice would stop the cpu from going to 99 when
> updating the cache or when searching.


Setting PORTAGE_NICENESS in /etc/make.conf will probably suffice.

> For the moment, though, I do not get email. Even after emerging
> mailx I still get nothing. Something's wrong with sendmail.


Something's wrong with your email setup, most likely.

> 09:00:06 [sSMTP] Unable to locate mail
> Feb 6 09:00:06 [sSMTP] Cannot open mail:25


Apparently you are (or the default config is) telling ssmtp (the
default email package you'll get if you don't install another one
to replace it, if I recall) that your mail server is called 'mail'.
If it's not, fix that. If you don't have one, install a mail server
package locally.

--
Time flies like an arrow, fruit flies like a banana. Perth ---> *
15:41:26 up 89 days, 22:15, 2 users, load average: 0.00, 0.00, 0.00
Linux 2.6.14 x86_64 GNU/Linux Registered Linux user #261729
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-21-2008, 11:03 AM
oKtosiTe
 
Posts: n/a
Default Re: running emerge --sync in cron

Johan Lindquist wrote:
> So anyway, it was like, 15:31 CET Feb 06 2006, you know? Oh, and, yeah,
> Peter was all like, "Dude,
>
>
>>Basically, adding nice would stop the cpu from going to 99 when
>>updating the cache or when searching.

>
>
> Setting PORTAGE_NICENESS in /etc/make.conf will probably suffice.

That's what I did.
>
>
>>For the moment, though, I do not get email. Even after emerging
>>mailx I still get nothing. Something's wrong with sendmail.

>
>
> Something's wrong with your email setup, most likely.
>
>
>>09:00:06 [sSMTP] Unable to locate mail
>>Feb 6 09:00:06 [sSMTP] Cannot open mail:25

>
>
> Apparently you are (or the default config is) telling ssmtp (the
> default email package you'll get if you don't install another one
> to replace it, if I recall) that your mail server is called 'mail'.
> If it's not, fix that. If you don't have one, install a mail server
> package locally.
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-21-2008, 11:03 AM
Peter
 
Posts: n/a
Default Re: running emerge --sync in cron

On Mon, 06 Feb 2006 15:49:12 +0100, Johan Lindquist wrote:

snip...
>> For the moment, though, I do not get email. Even after emerging mailx I
>> still get nothing. Something's wrong with sendmail.

>
> Something's wrong with your email setup, most likely.
>

Most definitely!

>> 09:00:06 [sSMTP] Unable to locate mail Feb 6 09:00:06 [sSMTP] Cannot
>> open mail:25

>
> Apparently you are (or the default config is) telling ssmtp (the default
> email package you'll get if you don't install another one to replace it,
> if I recall) that your mail server is called 'mail'. If it's not, fix
> that. If you don't have one, install a mail server package locally.


Well, I don't have a mail server. I just expected the mail to go to
/var/spool/mail/peter/mbox.

I looked for sendmail documentation, but there was none. Do I need to use
localhost?

Any docs you could refer me to is appreciated.

Thanks for the PORTAGE_NICENESS tip. I'll put that in.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com