autoshutdown?? [Solved]
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
autoshutdown?? [Solved]
There is a /.config/autostart folder for scripts that automatically run when booting. Is there a similar idea for scripts to run when shutting down?
A Chrome module I am trying creates a very large cache folder which gets saved in my save.dat file. I would like to purge it when shutting down rather than save it.
A Chrome module I am trying creates a very large cache folder which gets saved in my save.dat file. I would like to purge it when shutting down rather than save it.
Last edited by Ed_P on 23 Mar 2016, 18:24, edited 1 time in total.
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
rc.local_shutdown, but not sure if executed before saving changes. 

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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
Ok Bogomips that is where I have it but it isn't working.
rc.local_shutdown
chromecache.sh
No echos when shutting down. And the script works in terminal mode. I'm missing something.
rc.local_shutdown
Code: Select all
#!/bin/sh
#
# rc.local_shutdown
#
# This script is executed at shutdown (rc0) and reboot (rc6).
# You need to make it executable before using.
#
# Example:
# /etc/rc.d/rc.samba stop
/home/guest/chromecache.sh
Code: Select all
#!/bin/sh
if [ -d "/home/guest/.cache/google-chrome/Default/Cache/" ]; then
rm /home/guest/.cache/google-chrome/Default/Cache/*
echo "Chrome cache purged."
else
echo "No Chrome cache."
fi
-
- Contributor
- Posts: 686
- Joined: 26 Jun 2013, 14:03
- Distribution: x64 Openbox
- Location: Russia is causing the immense damage to humanity
- Contact:
Re: autoshutdown??
I think you can replace cache directory with symlink, for example symlink to /mnt/sda4/DefaultCache2 or to /mnt/ramd/cache (mkdir -p /mnt/ramd
mount ramdisk /mnt/ramd -t tmpfs -o size=105M
mkdir -p /mnt/ramd/cache
chown guest:guest /mnt/ramd/cache)
See at '/etc/changes-exit.conf' also.
mount ramdisk /mnt/ramd -t tmpfs -o size=105M
mkdir -p /mnt/ramd/cache
chown guest:guest /mnt/ramd/cache)
See at '/etc/changes-exit.conf' also.

- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
Well I found the problem with rc.local_shutdown, it needed to be made executable!!
http://forum.porteus.org/viewtopic.php? ... 696#p32711
Your symlink idea is interesting tome. I was thinking of finding a way to redirect the chrome cache to the /tmp/ directory to solve the savedata space issue. And doing that would eliminate the concern of hundreds of thousands of .wh. files from all the cache deletes.
http://forum.porteus.org/viewtopic.php? ... 696#p32711
Your symlink idea is interesting tome. I was thinking of finding a way to redirect the chrome cache to the /tmp/ directory to solve the savedata space issue. And doing that would eliminate the concern of hundreds of thousands of .wh. files from all the cache deletes.
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
@Ed Running in ram, and having not that much ram at my disposal, done more or less what you have in mind, within the guiexec script, for the PaleMoon cache: 
Code: Select all
mkdir .cache/'moonchild productions'
sudo mount --bind /mnt/sda4/PaleMoon/moonchild .cache/'moonchild productions'

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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
hmmmm Not working for me.
The part of the code failing:
And
But
The last error being understandable since chrome hasn't been run yet.
Code: Select all
guest@porteus:~$ chrome.sh
mkdir: cannot create directory ‘/tmp/google-chrome/Cache/’: No such file or directory
sudo: invalid option -- '-'
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] file ...
Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir /tmp/google-chrome
mkdir /tmp/google-chrome/Cache
sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
Code: Select all
guest@porteus:~$ ls /tmp
qtsingleapp-qlippe-2dfb-3e8= qtsingleapp-qlippe-2dfb-3e8-lockfile
guest@porteus:~$
Code: Select all
guest@porteus:~$ mkdir /tmp/google-chrome
guest@porteus:~$ mkdir /tmp/google-chrome/Cache
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$ ls /tmp/google*
Cache/
guest@porteus:~$ sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
guest@porteus:~$
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
Replace with:Ed_P wrote:Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then mkdir /tmp/google-chrome mkdir /tmp/google-chrome/Cache sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache fi
Code: Select all
set -x; # Diagnostic output
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir -p /tmp/google-chrome/Cache; # Less chance of invisible chars creeping in
sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
The results make no sense at all.Bogomips wrote:And let's see what we get.
Code: Select all
guest@porteus:~$ ls /tmp
qtsingleapp-qlippe-2dfb-3e8= qtsingleapp-qlippe-2dfb-3e8-lockfile
guest@porteus:~$ chrome.sh
+ '[' '!' -d /tmp/google-chrome/Cache/ ']'
+ mkdir -p /tmp/google-chrome/Cache/
+ sudo --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
sudo: invalid option -- '-'
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] file ...
+ read
+ google-chrome-stable 'https://us.forgeofempires.com/page/ '
^C
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$
Code: Select all
set -x; # Diagnostic output!!
if [ ! -d /tmp/google-chrome/Cache/ ]; then
mkdir -p /tmp/google-chrome/Cache/
sudo --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
fi
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
sudo mount -- bind 8)
-x shows step by step progress, a blow by blow account
btw your sudo ok? sudoers set and you don't have to submit pw?
Search for set in http://man.cx/bash
-x shows step by step progress, a blow by blow account

btw your sudo ok? sudoers set and you don't have to submit pw?
Search for set in http://man.cx/bash
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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
Bogomips wrote:sudo mount -- bind 8)

Will retest and get back to you.

- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
Ok, it seems to be working.
But more questions.
How does one turn off the set -x command?
Would accomplish the same thing as the mount --bind command?
I need to reboot and retry this without the set -x command.
OK
Code: Select all
guest@porteus:~$ chrome.sh
/mnt/sda5/porteus3.0/Modules/zchrome.xzm
Chrome ready to run. Press Enter when done using it.
+ '[' '!' -d /tmp/google-chrome/Cache/ ']'
+ mkdir -p /tmp/google-chrome/Cache/
+ sudo mount --bind /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
Password:Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
guest@porteus:~$ ls /tmp
google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
qtsingleapp-qlippe-2dfb-3e8=
guest@porteus:~$ ls /tmp/google*
Cache/
guest@porteus:~$
How does one turn off the set -x command?
Would
Code: Select all
ln -sf /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
I need to reboot and retry this without the set -x command.
OK
Code: Select all
guest@porteus:~$ chrome.sh
/mnt/sda5/porteus3.0/Modules/zchrome.xzm
Chrome ready to run. Press Enter when done using it.
Password:Password:
mount: mount point /home/guest/.cache/google-chrome/Default/Cache does not exist
Password:
/mnt/sda5/porteus3.0/Modules/zchrome.xyzm
guest@porteus:~$ google-chrome/ qtsingleapp-qlippe-2dfb-3e8-lockfile
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
set +xEd_P wrote: How does one turn off the set -x command?

Which is better I was wondering. Sometimes I've found symlink not to work, so prefer to do mount. AFAIK magic folders also use the mount.Ed_P wrote:Wouldaccomplish the same thing as the mount --bind command?Code: Select all
ln -sf /tmp/google-chrome/Cache /home/guest/.cache/google-chrome/Default/Cache
btw suggest enhancing by creating the cache directory:
Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then
mkdir -p /tmp/google-chrome/Cache;
c=/home/guest/.cache/google-chrome/Default/Cache
[[ ! -d $c ]] && mkdir -p $c
sudo mount --bind /tmp/google-chrome/Cache $c
fi
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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8908
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: autoshutdown??
The symlink I don't think would care if the .cache folder exists when executed. Not sure it also may not require sudo.Bogomips wrote:Which is better I was wondering. Sometimes I've found symlink not to work, so prefer to do mount. AFAIK magic folders also use the mount.
btw suggest enhancing by creating the cache directory:Code: Select all
if [ ! -d /tmp/google-chrome/Cache ]; then mkdir -p /tmp/google-chrome/Cache; c=/home/guest/.cache/google-chrome/Default/Cache [[ ! -d $c ]] && mkdir -p $c sudo mount --bind /tmp/google-chrome/Cache $c fi

I've really enjoyed this thread Bogomips. It's like the old days for me, asking questions and learning new things. Thank you.

Newest problem, running chrome I don't see anything in either cache location.


-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: autoshutdown??
Watch movie in browser and use:which is what I used in order to find the PaleMoon cache. 

Code: Select all
find . -xdev -size +70M

I'm all for sharing knowledge and learning new things, myself included.Ed_P wrote:I've really enjoyed this thread Bogomips. It's like the old days for me, asking questions and learning new things. Thank you.

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
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB