I want to make my own /tmp folder on one of my drives /media/Torrents How would I go about create a script to run on startup applications? I already have this script where it mounts the drive on boot: udisks --mount /dev/sdb2

The folder I want to get wiped every boot will be called .tmp


1 Answer 1


If I get the question right, you want a folder's content to be deleted on boot. The script could look like this:

rm -r "$folder"/*

To use it you only change the second line: replace /your/folder/here with the folder you want wiped. Then copy/paste it into an empty text file (not using something like libreoffice or Open Office, but with something like gedit). Save it as whateveryouwant.sh. Right click on it, go to "Properties"->"Permissions" and check the box to make it executable.

There are lots of options to run it at system start up. There should even be a graphical tool in Ubuntu to let stuff run at log in, that might be easiest if you don't need it earlier.

  • So if I'm correct for me it'll be: #!/bin/bash folder=/media/Torrents/.tmp rm -r "$.tmp"/*
    – Johnathon
    Aug 29, 2013 at 20:13
  • I wrote a general script on purpose because I don't understand your question completely. If the folder you want wiped is /media/Torrents/.tmp then you change the second line to folder=/media/Torrents/.tmp and leave everything else. You weren't supposed to edit the third line, the third line like I wrote it does the following: Remove everything inside the folder which you specified in the second line. You also can't remove the newlines I put in. You need to paste it into a file exactly like I wrote it.
    – Nobody
    Aug 29, 2013 at 20:18
  • Ah that makes sense now, yes I want to remove /media/Torrents/.tmp. Thank you very much!
    – Johnathon
    Aug 29, 2013 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.