Maritim og Marin IIoT - dokumentasjon

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Cron

To fetch data from different data providers several Python scripts were created to download the data and publish it to the MQTT-broker. In order to consistently fetch new data from different sources cron is utilized to make sure that the scripts are executed and disposed of properly. Each script is a cron job that is executed at a specific time and date. For example, the weather data scripts run every 5 mintues. A crontab holds every task and when it is scheduled to be executed.



Managing the cronjobs

To see the current cronjobs configured you use the following bash-command.

$ crontab -l

To edit or add cronjobs, the following bash-command is used.

$ crontab -e

Checking the status of running cronjobs can be done by the following bash-command.

$ sudo /etc/init.d/cron status

Or,

$ sudo grep CRON /var/log/syslog



Configuring cronjobs

The current configuration of the cronjobs are shown below.


# 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
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/aalesund.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/trondheim.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/hareid.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/festoy.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/solavaagen.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/magerholm.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/sykkylven.py
*/5 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/open-weather-map-scripts/sulesund.py
*/15 * * * * /usr/bin/timeout -s SIGTERM 600 /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/buoy-data/XarrayBuoyData.py >> /home/administrator1/Logs.txt 2>&1
12 * * * * /usr/bin/python3.7 /home/administrator1/scripts/mi-iot/simulations/dummy-ferry/ferry-sim.py




  • No labels