Monday, February 21, 2011

Soft Reboot (quick reboot)

I talked a bit about dropping caches to free up memory and jumpstart the kernel caching system a few times in my previous posts.  I think occasionally some of us would like to clean things up even more to keep the phone running smoother (ie. maybe you feel that the phone is running really sluggish).  One way to possibly accomplish this is to do a soft reboot.

Soft reboot would essentially kill all running processes and restart the essential services.  Anything at the OS layer or below, namely bootloader, kernel and init would not be restarted.  So you're rebooting your phone without touching the OS/bootloader, and all within just a matter of seconds.

Here's what you do to cause a soft reboot:
pkill zygote
That's it.  Zygote is an android service that initializes Dalvik and rest of the system.  By killing it, you basically kill all apps registered with zygote and restarts essential services including zygote.  (At least that's how I understand it haha).

If you've been reading my blog, you probably know all about crond on android.  You could potentially use crond to schedule a soft reboot once a week.  Your crontab file may look something like this:

# drop kernel caches at 3AM every morning
0 3 * * * sync; echo 3 > /proc/sys/vm/drop_caches
# soft reboot system at 2AM monday morning
0 2 * * 1 pkill zygote

There's one slight problem with this method. This soft reboot is more or less based on my theory and I have no idea what the long term effect would be if you continue to use this method.  Use it at your own risk! :)

6 comments:

  1. I'm running SEX10 on Eclair, and my busybox doesn't have pkill, but it does killall (which is the same).

    But, 'killall zygote' restart my phone cpmpletely, up to bootscreen. I'm not sure if it's a really 'soft' boot :)

    ReplyDelete
  2. On Droid x it skips the boot logo but will show the boot animation. One good way to check is to type uptime in terminal emulator.

    ReplyDelete
  3. Yeah, seems that it realy reboots it "softer" - thanks for article!

    ReplyDelete
  4. ok so im really new to all this. but if i type i pkill zygote nothing happens. idk if im doing something wrong or what. like i said new. i've never really messed with terminal commands, or any kind of code for that matter. but wanting to learn

    ReplyDelete
  5. William, are you running the terminal as su?

    ReplyDelete
  6. Thanks, i'm using SH Script Runner.
    The 'killall zygote'/'pkill zygote' properly worked!

    ReplyDelete