I have been using Qfiling to organize my file, but FileRun won’t be able to detect the changes of files automatically. Therefore, a
cron
job is needed to fetch the metadata of the files, so that I do not need to do that manually.
As I used the Owncloud’ to automatically upload my photos to a folder named Temp Photo
, and I used Qfiling on my QNAP NAS to organize the photos according to their taken date.
Since this task is performed outside of FileRun, it would not be aware of the changes of photo locations. Therefore, an automatically performed cron job would help me to fetch the metadata of the photos.
In FileRun’s documentation, they recommended two methods of adding cron job in a docker, by editing /etc/crontab
or by using the command crontab -e
.
I will focus on the latter method, as it is more straightforward.
Prepare a Bash File
I prepared a customcron.sh
file in /var/www/html/cron/
, the location is your choice and the command in the bash file is:
php /var/www/html/cron/metadata_index.php myusername /user-files/Multimedia/Photos/2022
Remember to make this bash file executable:
chmod 755 /var/www/html/cron/customcron.sh
Adding a Cron Job
After that I added a cron job by using crontab -e
(the task is performed every Tuesday at 0122):
22 1 * * tue /var/www/html/cron/customcron.sh
But simply by adding this command, that cron job was not working, after some debuggings, I found out the following error message:
/var/www/html/cron/customcron.sh: line 1: php: command not found
/var/www/html/cron/customcron.sh: line 2: php: command not found
In this case, what I need to do is simply add two more lines at the beginning to crontab by using crontab -e
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
22 1 * * tue /var/www/html/cron/customcron.sh
Voila, the cron job is working, it would automatically fetch the metadata of files.
Miscellaneous - This is how to get the log for a cron job in FileRun docker:
22 1 * * tue /var/www/html/cron/customcron.sh >> /var/log/cronjob.log 2>&1
Then you can find the cronjob.log
at /var/log/
.