Hallo zusammen, ich bin neu hier, und noch recht neu mit Linux und Ubuntu unterwegs, deshalb seht es mir bitte nach, wenn ich hier in der falschen Kategorie gelandet sein sollte. Da es sich sowohl um ein Shell Script, als auch um einen Dienst handelt, war ich mir nicht ganz sicher…
Zur Sache: Ich habe folgendes Script bei mir im Einsatz
1 2 3 4 5 6 7 8 9 | #!/usr/bin/env bash token='Meinen token' uri='ws://192.168.10.2:8001/stream' while read line do ntfy send "$(echo ${line} | jq -r '.message')" done < <(websocat -H "X-Gotify-Key: ${token}" -t "${uri}") |
Dieses kommt aus einer Anleitung, um Gotify Benachrichtigungen auf iOS Geräte zu bekommen (https://the-empire.systems/gotify-ios-notifications)
Wenn ich das Script im Terminal starte:
1 | ascheurer@lem-server:/opt$ ./gotify-sync.sh
|
funktioniert alles einwandfrei, Benachrichtigungen werden gesendet… Allerdings nur solange das Script auch läuft. Beende ich die Terminalsitzung, oder beende das Script mit „Control C“ damit ich weiter im Terminal arbeiten kann, dann funktioniert es natürlich nicht mehr.
Deshalb habe ich, wie in der Anleitung beschrieben, mit
1 | ascheurer@lem-server:~$ crontab -e |
einen Cronjob erstellt. Dieser sieht folgendermaßen aus:
# 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 screen -dmS gotify-sync /opt/gotify-sync.sh
Anschließend den Server neu gestartet, aber das Script wird nicht ausgeführt… und jetzt bin ich mit meinem Laien-Latein am Ende…
Wer kann mir da weiterhelfen?
Betriebssystem ist Ubuntu 20.04 LTS Server