0

I have problem with perl script. It works fine if i don't change destination path, but when I do in doesn't update my file in that destination. I got this script from web, but I want to change destination.

Updating works fine when its like this

 $rrd_out = '/usr/bin/rrdtool update /home/pi/temperature/rPItemp.rrd N:$temperature';

But when I change path to this

$rrd_out = '/usr/bin/rrdtool update /dev/shm/rPItemp.rrd N:$temperature';

I have created rrd file in that destination, but don't understand why it's not updating. Even from terminal I can see that this file executes and prints values but doesn't update that file in /dev/shm/rPItemp.rrd

Please help me.

Thanks.

4
  • It is obvious why it doesn't work. Only root has permission. Why do you want to put logged data into a directory reserved for devices? If you search this Forum you will find examples of others who have plotted temperature with rrdtool.
    – Milliways
    Oct 3, 2013 at 8:46
  • That's because I don't want to write data in my sd card all the time. I have other scripts witch does not mind to write data there, but this does. I even made new per scripts that just make new file there and write a something. But why this doesn't? Oct 3, 2013 at 8:51
  • The other script probably elevates itself in some way using 'sudo', maybe you could try using $rrd_out = 'sudo /usr/bin/rrdtool update /dev/shm/rPItemp.rrd N:$temperature';
    – PiBorg
    Oct 3, 2013 at 12:11
  • Have you solved your problem? If so, please mark the answer that helped you, or if you solved it on your own, create a self-answer and mark it as such. We are trying to get the site Q:A ratio up and marking answers is what does that. If you resolved it and mark then people in the future will be able to profit from what you did and it helps move the site closer to graduation. Thanks! Mar 23, 2014 at 16:58

2 Answers 2

1

If you're running an RRD with updates every few minutes, SD card wear won't be a problem in any reasonable amount of time.

But if you're determined to use an off-disk store, you can make a 1MB ramdisk this way:

sudo mkdir -m777 /mnt/scratch
sudo mount -t tmpfs -o size=1M tmpfs /mnt/scratch

Anything written to a file in /mnt/scratch won't hit the SD card. I don't know if a megabyte will be big enough for your database; try it.

If you want to have this ramdisk created at boot, add the following line to your /etc/fstab:

tmpfs /mnt/scratch tmpfs size=1M 0 0
0

Does the user you're running the perl script under have permissions to modify the path ?
Can you run ls -l /dev/shm and post the output ?
As a test, you can run chmod 777 /dev/shm/rPItemp.rrd and see if the script can update it then.

Edit
After reading some comments, if you don't want to keep writing to the SD Card, I'd recommend using a separate ramdisk with read/write permissions for everyone rather than putting into /dev/shm.

2
  • It has permissions rwxrwxrwx. But I should see if it modifies this file under properties and Last Modification right? I have another script that writes file there, and it works fine, and I can see that that files is modified Oct 3, 2013 at 8:34
  • What permissions on the directory /dev/shm ?
    – Lawrence
    Oct 3, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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