Jump to content
kjmclark

"/var/log" rebuilt every reboot - why?

Recommended Posts

I have Apache2 properly installed on my PCDuino3. Works great except that every time I reboot the system, the /var/log/apache2 folder disappears.  I did some more checking, and anything I put in /var/log disappears after reboot.  Any folder, any file that I put in there is gone the next time the system comes up.  I've tried chmod 777 on /var/log, on the apache2 folder once I've recreated it, no change.  I've also tried adding folders to /var, and there's no problem with that.  I haven't tried renaming one of the current log files in /var/log - don't know enough to avoid breaking something.

 

So, is there some reason that this folder is cleaned out every reboot?  This is killing my apache install, because every time the system starts, it tries to recreate its logs, but the folder is gone.  I'm thinking this is some MCU-based system issue, because there are no hits to this on searches, meaning most Linux users don't see this.

 

I noticed in another reply 'jim' recommended a script that would rebuild this folder each time.  IIRC, that was part of a shortcut.  I want apache started each boot, so if I have to use a script to recreate the folder every time, what file would I want to modify?

 

Thanks!

Share this post


Link to post
Share on other sites

I have Apache2 properly installed...

While reading your post (probably) exactly the same thing that jim recommended came to my mind. If I understood well, the only problem is that the file(s) are deleted from /var/log. If I were you, I would try to manually copy the content of /var/log (to some other place) before the reboot. After the reboot, try to put the files you have copied at the same place. I am sorry if you have tried this already. If this approach works, then it should be quite easy to create a script which will save the content of /var/log somewhere before the rebooting, and then another script which will move the content back where it should be after the boot.

 

If I didn't understand your problem or if you know why this approach cannot work, please let me know. Also, any other question is welcome. :)

Share this post


Link to post
Share on other sites

Thanks for your reply.  That doesn't really solve the problem.  I don't think Apache really cares if the old log files are restored - but it has a problem when it can't start because the /var/log/apache2 folder doesn't exist when it tries to start. 

 

Part of this is just that I don't understand what's going on.  There seems to be something special about /var/log that it gets wiped back to new every time.  I'm new at ubuntu - pcDuino, but this looks just like the newer behavior on Windows OS, where certain folders get rolled back to the last known good when you reboot, unless you did a proper install there. 

 

Two things would help.  First, someone saying that "Yes, /var/log is different, because of <X>, and these other folders are also different, you can read about that <here>".  I just don't know what to make of the behavior, so I don't know if it's a pcDuino design issue, an OS operation issue, or what.

 

The second would be something like "Yeah, you're not going to convice Ubuntu to leave a folder there, so the best thing you can do is add a few lines to <X>, <Y>, or <Z>, and they'll get run at boot to put that folder back.  "sudo mkdir /var/log/apache2" and "sudo chmod 777 /var/log/apache2" should be good enough."  Or, if there's some folder somewhere that overwrites /var/log every boot, "Just add an apache2 folder in <X> - that will put the folder in place for Apache automatically, everytime the system boots - that's how Ubuntu overwrites the folder each time anyway."

 

Thanks!

Ken

Share this post


Link to post
Share on other sites

OK, so I added those lines and the "service apache2 start" line to /etc/rc.local.  That seems to work OK.  Newb question, is that a bad way to handle that situation?  Next Newb question, when adding lines like that to scripts, should I use sudo?  I don't know what things are run as root and which are run as a user, and when that handoff is done.

 

Thanks!

Ken

Share this post


Link to post
Share on other sites

...is that a bad way to handle that situation...when adding lines like that to scripts, should I use sudo...

Well, since it works, of course it is not bad way (as long there are no consequences). Every workaround is highly desirable if it solves the problem without side effects.

 

Regarding the sudo, it depends on the line you are adding. You may try manually these commands to see whether they work just with sudo or they work without it as well. Some commands require sudo privileges and because of that you have to add them with it. However, if a command works without sudo, it is safer to use it like that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×