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.

2 Answers2

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
scruss
  • 9,117
  • 1
  • 25
  • 36
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.

Lawrence
  • 2,692
  • 15
  • 14