4

TL;DR: How can I set up either via a bash command executed as user or a bash command executed only once as sudo a temporary directory in $HOME which has the same behavior as the global /tmp directory?

Having upgraded my system to ubuntu 20.04 I am stumbeling upon a problem related to the temporary directory /tmp, snap and chromium.

I have written a small bash script which translate some log file to an html file, which is then opened in chromium. The html files are stored in /tmp because they are large and it is very likely, that I won't need them any more in the near future / after the next reboot. All worked well on ubuntu 18.04.

I recently upgraded my system to ubuntu 20.04, where chromium is installed via snap and does not have access to /tmp because of some reasons I do not understand. Regardless, I have to accept this behavior (doesn't seem like anything is changing soon) and have to think of a work around. While searching the WWW I stumbled upon the idea of a user-specific temporary directory stored in $HOME, which would solve all my problems, because chromium/snap can access $HOME. However, I do not want to put much thought into creating and cleaning this tmp directory by myself. I am hoping of a way to easily create a $HOME/tmp directory which is cleaned up in the same manner as /tmp.

I already read about pam_tmpdir but couldn't find out if and how this could help. I know about mktemp but these files are not cleaned up on restart, if not created in /tmp. I thought about creating the file in /tmp/snap.chromium/tmp because chromium seems to have access to this, but user don't and the folder is only created at the first start up of chromium which is to late. Creating an entry in crontab with @reboot is an option, but I don't like it. And if I am not mistaken, /tmp cleaning can be changed so that clean up is not only performed on reboot.

Hopefully somebody reading this has a great idea how to solve my problem.

Your Answer

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

Browse other questions tagged or ask your own question.