/tmp and /var/log cleanup at boot

Post here if you are a new Porteus member and you're looking for some help.
michalh
White ninja
White ninja
Posts: 13
Joined: 20 Mar 2017, 14:41
Distribution: Porteus Desktop
Location: Czech Rep.

/tmp and /var/log cleanup at boot

Post#1 by michalh » 23 Mar 2017, 09:07

Hi,

I do not want to preserve changes to(in) /var/log and /tmp dirs, how to make them fresh clean at every boot?

Thanks, Michal

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: /tmp and /var/log cleanup at boot

Post#2 by fulalas » 23 Mar 2017, 21:48

Open /etc/rc.d/rc.local, create a new line in the end and put this:

Code: Select all

echo guest | sudo -S rm -rfd /var/log/*
echo guest | sudo -S rm -rfd /tmp/*
If you're not using save-changes cheatcode, then create /porteus/rootcopy/etc/rc.d/rc.local inside your Porteus bootable device and write the commands above.

Another option is to delete them at shutdown process. Use the same commands above, but inside: /etc/rc.d/rc.local_shutdown

michalh
White ninja
White ninja
Posts: 13
Joined: 20 Mar 2017, 14:41
Distribution: Porteus Desktop
Location: Czech Rep.

Re: /tmp and /var/log cleanup at boot

Post#3 by michalh » 27 Mar 2017, 05:34

rc.local is run before any other programs, which can write to /tmp and /var/log?

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: /tmp and /var/log cleanup at boot

Post#4 by fulalas » 27 Mar 2017, 05:55

Yes, it is. But maybe it's better to use the shutdown script :)

Bogomips
Full of knowledge
Full of knowledge
Posts: 2564
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: /tmp and /var/log cleanup at boot

Post#5 by Bogomips » 29 Mar 2017, 11:43

michalh wrote:rc.local is run before any other programs, which can write to /tmp and /var/log?
Not so sure here. In the Web seen posts asserting that rc.local is first to be run, but after doing a diagnostic, it seems rc.S runs before rc.local.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

Post Reply