Remove temp folder contents on shutdown

By Ali Karbassi | January 14th, 2007 | Ubuntu

A few days ago Codejacked wrote an article talking about Delete your TEMP files on shutdown for Windows. As much as I loved the article, I have recently switched over to Ubuntu. Like all Operating Systems, GNU Linux has temporary files also. Here’s how to delete them on shutdown.

  1. Back up what you’re going to working on.
    sudo cp /etc/init.d/sysklogd /etc/init.d/sysklogd_backup
  2. Open the file in gedit
    gksudo gedit /etc/init.d/sysklogd
  3. Find the following section
    ...
     stop)
      log_begin_msg "Stopping system log daemon..."
      start-stop-daemon --stop --quiet --oknodo --exec $binpath --pidfile $pidfile
      log_end_msg $?
    ...
  4. Add the following line after log_end_msg $? or before ;;.
    rm -fr /tmp/* /tmp/.??*
  5. Save the file and you’re set!

One Response to “Remove temp folder contents on shutdown”

  1. [...] If you’re using linux, check out this: http://tech.karbassi.com/2007/01/14/remove-temp-folder-con... [...]

Leave a Reply