LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how can i pre-load applications into ram automatically at startup??? (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-pre-load-applications-into-ram-automatically-at-startup-116011/)

win32sux 11-14-2003 12:58 PM

how can i pre-load applications into ram automatically at startup???
 
you know how once you open an application and then close it most of it's "stuff" is cached in ram and the swap partition, so as that next time you open your application it will load that "stuff" from there (ram, swap) and open much faster than the first time???

i'd like to make my parent's linux box pre-load some apps into ram automatically at every system startup so that when they click an icon the apps will load much faster than if they weren't cached...

i'm thinking about doing this to mozilla and openoffice.org, for example, but i don't know how to do this yet, so i am hoping someone like you will show me the way...

850mhz (amd duron) / 128mb pc-133 / nvidia tnt2 - it's a mandrake 9.1 box but i'd like to learn how to do it in a non-distro-specific way if possible...

i'd really appreciate any help you could give me... thanks!

TheOther1 11-15-2003 03:04 PM

You could create a ramdisk and copy the desired programs into the ramdisk but with 128 MB RAM, you would be limiting the efficiency of Linux... :(

You could add these to autostart but then they would actually load and start at each login.

win32sux 11-15-2003 04:47 PM

hello TheOther1 and thanks for your input!

i'm looking to make it load and close the applications just like normal (from the disk, but behind the scenes) so as that the regular (super excellent) linux memory management goes into effect without creating a ramdisk to load the apps from (which would, as you stated, take a large slice from my little bit of ram)...

i think i should mention that the machine is set to auto-login, my aim is to make it load the applications inside the auto-logged-in account.... perhaps in such a way that ONLY the auto-logon account pre-loads (and closes) the applications for itself and all other accounts behave like normal...

setting the applications to load on account startup is exactly what i want, but i need for it to happen BEHIND THE SCENES (it would suck to actually SEE all the apps loading every boot and having to close them by clicking) and for them to auto-close after loading:

- computer boots

- auto-login

- gui loads (perhaps temporarily disabled while the next step completes)

- selected applications are loaded in the background and immediatley closed (killed?)

- desktop is presented as usual (except the "pre-loaded" apps will already have most of their "stuff" in ram and swap so they'll load quickly)...


i'm sure this would be done using a shell script set to run on account log-in... maybe there's a modifier or something you can put after any command to make it happen in the background (a la "wget -b")? then it could be just a matter of setting the script to do a "kill" on the process after the app loads?

TheOther1 11-15-2003 05:25 PM

Maybe a bash script that looks something like this?:

#! /bin/sh
mozilla &
otherapp &
sleep 2
kill `ps aux | grep mozilla | grep -v grep | awk '{print $2}'`
kill `ps aux | grep otherapp | grep -v grep | awk '{print $2}'`


That would start apps, sleep for 2 seconds to give apps a chance to start, locate pid of mozilla and kill it, find pid of otherapp (replace with app name) and kill it. :cool:

teval 11-16-2003 10:08 AM

You could just do..
killall -9 mozilla-bin instead of all that kill `....`

Note that this isn't going to work on startup.
You need to already have a working xsession or mozilla is going to fail and complain about no X.

TheOther1 11-16-2003 10:47 AM

Not sure, but I would be willing to bet the kill `....` process is actually faster (by milliseconds) than killall since killall calls kill, fuser, pgrep, pidof, and ps. Who knows?

teval 11-16-2003 11:26 AM

Possibly.. but it's simpler to read :) and make out what it means for people who are new.

TheOther1 11-16-2003 03:50 PM

True!

win32sux 12-07-2003 05:30 PM

thanks, you guys!

sorry for not posting in such a long time... i was away from information technology for a few weeks...

the shell script works very well... i created an ".xsession" file in my parent's home directory (so that the script will run when X starts) with this in it:

mozilla &
swriter &
sleep 55
kill `ps aux | grep mozilla | grep -v grep | awk '{print $2}'`
kill `ps aux | grep OpenOffice | grep -v grep | awk '{print $2}'`
exec /usr/bin/X11/blackbox


all i changed was the sleep time, so the apps could open completely before the kill (openoffice.org would act funky after getting killed while still loading, etc.)... and of course i added the line at the end so that the window manager would be started after everything was killed...

so now linux boots up, auto-logs in, starts X, starts mozilla and swriter (while waiting for 55 seconds*), kills them and their family, and then runs the window manager with all the "stuff" cached... which is exactly what i was looking for so once again THANK YOU SO MUCH!!!

the only thing that sucks is that one can actually "use" the apps during the pre-load... you innocently begin to type in a URL in mozilla and before you hit enter everything gets killed and you have an "explorer.exe crash flashback"... LOL

it would be rad if you couldn't SEE the pre-loading apps, and if the keyboard and mouse clicks were disabled during this pre-load process... some kinda message box or status bar letting you know what's going on would be even more rad (radder?)... i'm googling around for this stuff but as always your input is greatly appreciated...

by the way, normally openoffice.org takes 30 seconds to open on this machine... now with this pre-loading it takes 10!!!

=)





* it's cool, they usually turn the pc on (in the morning) and go make coffee before actually using it... =)

teval 12-07-2003 08:47 PM

From mozilla --help

-height <value> Set height of startup window to <value>.
-width <value> Set width of startup window to <value>.

openoffice probably has that too, just set it to 1 and 1 or 0 and 0, that should fix it :)

Nic-MDKman 02-24-2004 05:20 AM

No matter what, with 128MB of ram, you are already hindering performance. If you use ramdisk, or try to preload the programs into memory, you are still going to be using nearly equal amounts of ram. Save yourself a headache and get some more memory. Memory is dirt cheap now, and you will see improved performance in the system alone by adding more memory. The only system that I have only 128MB of ram in is my Pentium 150 laptop, because that is all it can read. With an 850mHz system you will see a substantial speed increase by doubling the ram.


All times are GMT -5. The time now is 04:21 PM.