View previous topic :: View next topic |
Author |
Message |
Accipiter Tux's lil' helper


Joined: 24 Feb 2003 Posts: 89 Location: Buffalo, NY
|
Posted: Sat May 24, 2003 9:19 pm Post subject: Using Emerge under Cron (with new Portage feature) |
|
|
*** Resolved: See last post for details.
The problem is pretty straightforward. I have this line in my crontabs (vcron):
Code: | 0 12 * * * /usr/bin/emerge sync && /usr/bin/emerge -u world |
When the cron job is run, the following output is mailed to me:
Code: | Traceback (most recent call last):
File "/usr/bin/emerge", line 279, in ?
emergelog("Started emerge on: "+time.strftime("%b %d, %Y %H:%M:%S", time.localtime()))
File "/usr/bin/emerge", line 186, in emergelog
xtermTitle(mystr)
File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
myt=os.environ["TERM"]
File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
def __getitem__(self, key): return self.data[key]
KeyError: TERM
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.2/atexit.py", line 20, in _run_exitfuncs
apply(func, targs, kargs)
File "/usr/bin/emerge", line 201, in emergeexit
emergelog(" *** terminating.")
File "/usr/bin/emerge", line 186, in emergelog
xtermTitle(mystr)
File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
myt=os.environ["TERM"]
File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
def __getitem__(self, key): return self.data[key]
KeyError: TERM |
The emerge never happens, as the output indicates. It just seems to fork off and die. This occurs whether the reference in the crontab is "/usr/bin/emerge" or simply "emerge." Using emerge at the command line functions normally. Why is this happening? I've rifled through the entire forum. Other people seem to have analogous setups and it works fine for them. How can I remedy this?
Last edited by Accipiter on Sun May 25, 2003 8:34 pm; edited 1 time in total |
|
Back to top |
|
 |
evanduser n00b

Joined: 09 Apr 2003 Posts: 22
|
Posted: Sun May 25, 2003 6:51 pm Post subject: Re: vcron and emerge won't play nice |
|
|
This is a new feature of portage-2.0.48. It was documented in a submitted bug several days ago (can't find it again...sorry). Basically, emerge requires that it have the TERM enviornment variable set. This true for a shell session, but not for a cron job which is running detached from the console. I sync my portage tree nightly and email myself with a emerge -vp system to see what is new.
Here is my fix that works:
Code: | echo -e "\nUpdating portage -"
(export TERM="linux"; /usr/bin/emerge sync 2>&1) >/dev/null
if [ "$?" -eq 0 ]
then
echo -e "Portage updated = OK"
else
echo -e "Portage update = Failed"
fi
echo -e "Listing update candidate packages\n"
( export TERM="linux"; emerge -vp system)
|
Hope this helps  |
|
Back to top |
|
 |
Accipiter Tux's lil' helper


Joined: 24 Feb 2003 Posts: 89 Location: Buffalo, NY
|
Posted: Sun May 25, 2003 8:31 pm Post subject: TERM |
|
|
Consider this. Cron (or vcron, at least) seems to support the export of environment variables in the crontab file. Using crontab -e, I added the following line just prior to the actual tab entries:
This behavior is documented in crontab(5) under the "Description" header. The following crontab line, therefore, works nicely, mailing only the error output of 'sync' and potential updates to the crontab owner (modify to your liking):
Code: | 0 0 * * * emerge sync >> /dev/null && emerge -Dvup world |
Thank you for your help.  |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|