Postingan sebelumnya, mengambil foto dan memberi nama berurutan secara otomatis sehingga tidak menimpa file sebelumnya ada pada link :
https://catatanraspberry.blogspot.com/2021/12/mengambil-foto-dengan-raspberry-pi-dan.html
file di atas disimpan dengan nama camera.py
Selanjutnya untuk bisa membuat scipt di atas berjalan secara otomatis, maka menggunakan fitur crontab.
fitur tersebut tidak akan dijalaskan di sini, langsung ke implementasi nya.
Yang Di Mau :
- Raspberry mengambil foto secara otomatis setiap 5 menit sekali / 5 jam sekali / 1 hari sekali dll.....
- Foto lama tetap ada dan tidak ditimpa dengan foto yang baru
Langkah :
- Buka crontab dengan perintah crontab -e
- Tambahkan di baris terakhit */5 * * * * python3 /home/pi/camera.py
Screenshot :
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#@reboot python3 /home/pi/led.py
#* * * * * python3 /home/pi/led.py
*/5 * * * * python3 /home/pi/camera.py # -----> tambahkan baris ini
penjelasan lengkap tentang crontab di sini : https://www.geeksforgeeks.org/crontab-in-linux-with-examples/
Supaya ga pusing bisa menggunakan website https://crontab.guru/ membantu menentukan script
reboot raspberry untuk melihat hasil nya, dan tunggu setiap 5 menit akan muncul foto1.jpeg, foto2.jpeg, dst......
Comments
Post a Comment