You are not logged in.

#1 2012-02-01 00:43:08

Never
Member
Registered: 2008-07-01
Posts: 103

Best way to handle a full /tmp tmpfs from python

Hi, I have this python program that write several files per day to a harddrive.  I check on it now and then and noticed this errors at the end of an attempted write:

IOError: [Errno 28] No space left on device

also

Filesystem      Size  Used Avail Use% Mounted on
rootfs           72G  3.1G   66G   5% /
udev             10M     0   10M   0% /dev
/run             10M  136K  9.9M   2% /run
/dev/hda2        72G  3.1G   66G   5% /
shm             755M  488K  755M   1% /dev/shm
tmpfs           755M  722M   34M  96% /tmp

and finally

#
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
tmpfs           /tmp    tmpfs   nodev,nosuid    0       0
# DEVICE DETAILS: /dev/hda1 UUID=2296a6d7-0915-4660-a822-5aba972b8842 LABEL=swap
# DEVICE DETAILS: /dev/hda2 UUID=ccfe994d-2a96-4d9d-8d6b-b8f93eb6b637 LABEL=/
UUID=2296a6d7-0915-4660-a822-5aba972b8842 swap swap defaults 0 0
UUID=ccfe994d-2a96-4d9d-8d6b-b8f93eb6b637 / ext3 user_xattr,defaults 0 1

So I am gonna go out on a limb here and assume my program tried to write a file to file and the /tmp was full so there was no space to write it, solution? Needs to be cleared. Question, how should I go about it? Should I just end up writing some catch to the exception that runs a script to remove all the files in the /tmp folder?

sudo rm -fr /tmp/*

Is there a way for the system to dump the tmp folder automatically once it reaches a certain size?  If I were going to use the code above, how would I make a script would take my sudo password when it is asked and complete the rest of the process? Any more elegant solutions? Thanks.

Offline

#2 2012-02-01 01:08:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Best way to handle a full /tmp tmpfs from python

What was in your /tmp? Maybe you can make it bigger? Maybe you can e.g. compile stuff outside /tmp?

Offline

#3 2012-02-01 01:20:26

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,547

Re: Best way to handle a full /tmp tmpfs from python

I certainly wouldn't want any program to start deleting anything that it didn't create.

Offline

#4 2012-02-01 05:14:18

Never
Member
Registered: 2008-07-01
Posts: 103

Re: Best way to handle a full /tmp tmpfs from python

This is my df -h from when I wiped it out with rm -fr /tmp/*

Filesystem      Size  Used Avail Use% Mounted on
rootfs           72G  3.1G   66G   5% /
udev             10M     0   10M   0% /dev
/run             10M  136K  9.9M   2% /run
/dev/hda2        72G  3.1G   66G   5% /
shm             755M  476K  755M   1% /dev/shm
tmpfs           755M   32K  755M   1% /tmp

I started my program, it did what it does and started loading the system up with files it was made to create. After running for just this period of time this is the new result

Filesystem      Size  Used Avail Use% Mounted on
rootfs           72G  3.2G   66G   5% /
udev             10M     0   10M   0% /dev
/run             10M  136K  9.9M   2% /run
/dev/hda2        72G  3.2G   66G   5% /
shm             755M  476K  755M   1% /dev/shm
tmpfs           755M   31M  725M   5% /tmp

again nothing but the program is running here, so after so many writes to disk /tmp will fill and that IO error will generate again, making the /tmp folder bigger or not having some automated way to dump /tmp are  band aid and non-solutions.  I am not sitting at this system, the idea is for it to do its work and for me to review the files from time to time. Shutting it down or rebooting are not viable options [that dumps /tmp].

What I am looking for is an intrinsic way to handle the /tmp file size capping out or I am stuck making a bash script that will remove it for me when my program generates that IO error. The thing I don't know, is when you sudo in a script how do you give your sudo enabling password? If no one can tell me, I suppose i can find it out, just thought I would ask while I have you. Also if you know of a way to just tell lunix to dump /tmp when it is full, that would be great. Thanks

Offline

#5 2012-02-01 05:50:26

Jristz
Member
From: America/Santiago
Registered: 2011-06-11
Posts: 1,022

Re: Best way to handle a full /tmp tmpfs from python

in fstab

tmpfs           /tmp    tmpfs   nodev,nosuid,size=2G    0       0

t'is make you /tmp a 2G sized (you need reboot or remount for take efect)
if you want more space add more, but I heard that a /tmp more big than you ram is buggy (but forme i never have any issue )


Well, I suppose that this is somekind of signature, no?

Offline

#6 2012-02-01 06:18:44

Never
Member
Registered: 2008-07-01
Posts: 103

Re: Best way to handle a full /tmp tmpfs from python

or a completely different place for this program to dump its temp data when writing to file

Offline

#7 2012-02-01 06:52:48

Never
Member
Registered: 2008-07-01
Posts: 103

Re: Best way to handle a full /tmp tmpfs from python

Jristz wrote:

in fstab

tmpfs           /tmp    tmpfs   nodev,nosuid,size=2G    0       0

t'is make you /tmp a 2G sized (you need reboot or remount for take efect)
if you want more space add more, but I heard that a /tmp more big than you ram is buggy (but forme i never have any issue )


Yes I could, but it seems like I will just face the same issue at a higher capacity.

Offline

Board footer

Powered by FluxBB