Tuesday, May 13, 2014

Raspberry Pi Picture Frame Post 8 Event Scheduler

Problems

Now for those of you who have been following along I have been doing some testing and found out that there is a slight problem with what I was doing. To make my life easier I have been keeping all of my scripts located in my google drive folder that syncs. This way I can edit them on my computer instead of having to do it via a command prompt. For the most part I still do edit them in the command prompt but it gives me options and I like options. It also means that for those of you who wants to replicate what I have done all of the files you download will always be up to date with what is on my device since I have just shared those folders with you. Now the flaw. Originally I created a user named slideshow which was the one who automatically logged on. Well do to the fact that my google drive sync folder is located in the pi user's folder the slideshow user needed special access which I do not know how to do. It keeps asking me for the su password or the password for slideshow which I did not have one setup for. So after not being able to figure out what the problem was I decided to change the auto login from user slideshow to user pi. I also had to add to the pi boot file the script to run the slideshow right away. {{sudo nano ~slidespihow/.bashrc}} add {{/home/pi/drive/scripts/slideshow.sh}} to the end of that file. Now when I reboot the slide show starts up right away.

Event Scheduler

Built into the pi os is an application called cron. this is an event scheduler. It is actually really easy to use. To open it the command is {{crontab -e}}. This will bring up a text file where you can create your tasks and when they will run. there are 6 parameters that we need to file in and they are {{m h  dom mon dow   command}}
  • m =what minute of the hour do you want
  • h = what hour of the day
  • dom = day of month
  • mon = month
  • dow = day of week
Somewhere along the line I read that fbi will fill the ram up or something along those lines and cause the pi to crash but it takes a rather long time to do that. Simplest solution to this problem is to restart the pi once a day. I also what grive to check for changes once a day so I made a script that will check google for changes, update what needs to be done and the reboot the picture frame so that the memory will clear and the new pictures will be displayed. That file is called grive.sh in my scripts folder. I randomly picked 1 am because this is going to be a present for my mom and rarely will she be up at that point so it will not bother anything. here is the line to make that happen {{0 1 * * * sh /home/pi/drive/scripts/grive.sh}} Now you may be wondering why *. Cron only runs the command if all of the place holders are true. so for my task it will run at minute 0 hour 1 of every day of every month of every day of the week. Now for my weather I am going to have that update every half hour. {{0,30 * * * * sh /home/pi/drive/scripts/weather.sh}} You see how I have 0,30. What that is going to do is at 0 minutes and 30 minutes of each hour of each day of each month of each day of the week run that command. you can do the same thing with each other holder. I also belive you can do ranges like 2-9, but don't quote me on that.

This project is really starting to come together now. Only a few things left to go.

No comments:

Post a Comment