{"id":332,"date":"2010-08-03T19:20:38","date_gmt":"2010-08-03T17:20:38","guid":{"rendered":"http:\/\/tronche.com\/blog\/less-technical\/uncategorized\/2010\/08\/etc-cron-daily-exim4-base-exited-with-return-code-123\/"},"modified":"2010-08-03T19:20:38","modified_gmt":"2010-08-03T17:20:38","slug":"etc-cron-daily-exim4-base-exited-with-return-code-123","status":"publish","type":"post","link":"https:\/\/tronche.com\/blog\/2010\/08\/etc-cron-daily-exim4-base-exited-with-return-code-123\/","title":{"rendered":"\/etc\/cron.daily\/exim4-base exited with return code 123"},"content":{"rendered":"<p>The problem has been reported [http:\/\/bugs.debian.org\/cgi-bin\/bugreport.cgi?bug=501892 here], but I&#8217;m not sure the solution was clearly stated.<\/p>\n<p>I got this under Ubuntu 9.04, exim4 4.69-9ubuntu1.<\/p>\n<p>In short, the problem is caused by the following lines in <tt>\/etc\/cron.daily\/exim4-base<\/tt>:<\/p>\n<p> + find \/var\/spool\/exim4\/db -maxdepth 1 -name *.lockfile \\<br \/>\n    -or -type f -printf %f\\0<br \/>\n + su &#8211; &#8211;shell \/bin\/bash &#8211;command xargs -0r -n 1 \\<br \/>\n    \/usr\/sbin\/exim_tidydb \/var\/spool\/exim4 > \/dev\/null Debian-exim<\/p>\n<p>These two lines find files in <tt>\/var\/spool\/exim4\/db<\/tt>, where live various databa<br \/>\n<!--more--><br \/>\nThe problem has been reported [http:\/\/bugs.debian.org\/cgi-bin\/bugreport.cgi?bug=501892 here], but I&#8217;m not sure the solution was clearly stated.<\/p>\n<p>I got this under Ubuntu 9.04, exim4 4.69-9ubuntu1.<\/p>\n<p>In short, the problem is caused by the following lines in <tt>\/etc\/cron.daily\/exim4-base<\/tt>:<\/p>\n<p> + find \/var\/spool\/exim4\/db -maxdepth 1 -name *.lockfile \\<br \/>\n    -or -type f -printf %f\\0<br \/>\n + su &#8211; &#8211;shell \/bin\/bash &#8211;command xargs -0r -n 1 \\<br \/>\n    \/usr\/sbin\/exim_tidydb \/var\/spool\/exim4 > \/dev\/null Debian-exim<\/p>\n<p>These two lines find files in <tt>\/var\/spool\/exim4\/db<\/tt>, where live various databases used by exim, and perform an exim_tidydb on each file. The files matching *.lockfile are filtered out.<\/p>\n<p>exim_tidydb thinks there are live databases, and thus try to acquire the lock in file xxx.lock for a file named xxx. This is where the problems occurs.<\/p>\n<p>In my case, there is another file in the directory, left by some upgrade script:<\/p>\n<p> # cd \/var\/spool\/exim4\/db\/<br \/>\n # ls<br \/>\n retry  retry.lockfile  wait-remote_smtp<br \/>\n wait-remote_smtp.lockfile  wait-remote_smtp.old<\/p>\n<p>The faulty file is <tt>wait-remote_smtp.old<\/tt>. When operating on it, exim_tidydb tries to acquire non-existent lock <tt>filewait-remote_smtp.old.lockfile<\/tt> and fails.  <\/p>\n<p>The solution: just delete that spurious <tt>wait-remote_smtp.old<\/tt> or move it elsewhere.<\/p>\n<p>== How did I come to that ? ==<\/p>\n<p>By manually stepping through the script lines:<\/p>\n<p>First I replaced the first line of <tt>\/etc\/cron.daily\/exim4-base<\/tt><br \/>\n #!\/bin\/sh<br \/>\nby<br \/>\n #!\/bin\/sh -x<\/p>\n<p>This way, the cron output contains every steps done by the script. This is how we spot the 2 faulty lines. Then in order to understand what&#8217;s going on, we just play the lines:<br \/>\n # cd \/var\/spool\/exim4\/db<br \/>\n # find \/var\/spool\/exim4\/db -maxdepth 1 -name *.lockfile -or -type f -print<br \/>\n \/var\/spool\/exim4\/db\/retry<br \/>\n \/var\/spool\/exim4\/db\/wait-remote_smtp.old<br \/>\n \/var\/spool\/exim4\/db\/wait-remote_smtp<\/p>\n<p>Now a line a bit tricky. The scripts runs as user <tt>Debian-exim<\/tt> , so we want to do that too. However this user has no login shell, as a security measure. We thus have to specify a working shell:<\/p>\n<p> # su &#8211; -s \/bin\/bash Debian-exim<\/p>\n<p>Now we can do our tests:<\/p>\n<p> # \/usr\/sbin\/exim_tidydb \/var\/spool\/exim4 retry<br \/>\n Tidying Exim hints database \/var\/spool\/exim4\/db\/retry<br \/>\n Tidying complete<\/p>\n<p>Doesn&#8217;t look bad. Another one:<\/p>\n<p> # \/usr\/sbin\/exim_tidydb \/var\/spool\/exim4 wait-remote_smtp<br \/>\n Tidying Exim hints database \/var\/spool\/exim4\/db\/wait-remote_smtp<br \/>\n Tidying complete<\/p>\n<p>So what ? Let&#8217;s try the last one:<br \/>\n # \/usr\/sbin\/exim_tidydb \/var\/spool\/exim4 wait-remote_smtp.old<br \/>\n Tidying Exim hints database \/var\/spool\/exim4\/db\/wait-remote_smtp.old<br \/>\n ** Failed to open database lock<br \/>\n file \/var\/spool\/exim4\/db\/wait-remote_smtp.old.lockfile:<br \/>\n No such file or directory<\/p>\n<p>Gotcha.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>The problem has been reported [http:\/\/bugs.debian.org\/cgi-bin\/bugreport.cgi?bug=501892 here], but I&#8217;m not sure the solution was clearly stated. I got this under Ubuntu 9.04, exim4 4.69-9ubuntu1. In <a class=\"mh-excerpt-more\" href=\"https:\/\/tronche.com\/blog\/2010\/08\/etc-cron-daily-exim4-base-exited-with-return-code-123\/\" title=\"\/etc\/cron.daily\/exim4-base exited with return code 123\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/comments?post=332"}],"version-history":[{"count":0,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"wp:attachment":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}