Jump to content


Photo

Folders & files in /var/log/ keep disappearing!


  • Please log in to reply
5 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:17 PM

Hi,

I have installed LAMP and it is working really well, until I reboot the system.  Apache doesn't start up and complains that it can't find the /var/log/apache2 directory for it to write log files to. 

I then create the directory, which appeases Apache, and it starts up nicely again.

It seems that after every reboot, the /var/log/apache2 folder keeps disappearing, and so I have to recreate it every time.

It has the same owner, group (root) and permissions as other folders in that directory so I am not sure what is going on.

Is anyone else using apache2?

I tried creating other folders and put dummy test log files in /var/log/ and they disappear as well!  Is there a 'berbudaTriagle -no_way' command available? 

I am new to Linux so any advice would be appreciated.

Thanks,
macro

PS  Where are all those files and folders going?  Are they appearing out of a worm-hole at the other side of the universe somewhere?



#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:18 PM

By default /var is a tmpfs file system... it is recreated on each boot. This is done to lower the write cycles to the flash memory and to keep from filling the permanent storage.

There are two simple solutions available to you. First, you can add commands /etc/rc.local to create the necessary directory in /var/log on each boot. Alternatively, you can choose to not have /var/log as a tmpfs -- just comment out the in /etc/fstab. 

Enjoy!
Bill



#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:18 PM

Thanks Bill,  I didn't know that about the /var directory.  I must have missed a step that told me that.

I went another way to fix the problem in the hope that it wouldn't increase the write cycles.  It seems to work well, but do you see any possible hitches with the following?


I edited Apache's environment variables file ( /etc/apache2/envvars ) by commenting out:
#export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

and adding:
export APACHE_LOG_DIR=/etc/apache2$SUFFIX


I then created a file called:
/home/ubuntu/.config/autostart/StartApache.desktop

that contained the following:
[Desktop Entry]
Type=Application
Exec=sudo service apache2 restart


As I said all runs well but as I am new to this I thought I better check.   undecided.gif



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:18 PM

This will be writing to your /etc directory instead of the /var/log. Meaning you will be writing to your flash. Also, the log file will not be in the log rotation list, so may eventually fill all available space in your root file system.

A better solution would be updating /etc/rc.local with this line (immediately before the 'exit 0'):

Code: [Select]

mkdir -p /var/log/apache2
By updating /etc/rc.local, you should not need to restart the apache2 service with a desktop autostart item.

Enjoy!
Bill



#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:18 PM

I understand now.  I am grateful for your reply, and so is my flash!

I added the entry to /etc/rc.local as you suggested and it works great now.

Thanks again for your help.   smiley.gif



#6 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 04:18 PM

Having encountered the same problem, I stumbled onto this thread.  Even after commenting the line out of fstab, I found that /var/log/apache2 would STILL disappear or reboot.  Only after I put a dummy file in the folder did it quit getting deleted.  I don't know if that lucky happenstance or some rational, explainable behavior.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users