I've been trying to create a new systemd timer to run a simple script that pushes my Obsidian vault to a private git repository. It is as close to identical as I can get to another systemd timer that I've had running for months that triggers a scrutiny collector script.
The script I'm trying to run is:
$cat /root/obsidian_gitpush.sh
# Go to /config folder or
# Change this to your docker config folder if it is different
cd "/datastore/configs/obsidian/mikes_wiki/"
# Add all files to the repository with respect to .gitignore rules
git add .
# Commit changes with message with current date stamp
git commit -m "Obsidian Vault Backup on `date +'%d-%m-%Y %H:%M:%S'`"
# Push changes towards GitHub
git push -u origin master
obsidian_github_sync.service:
[Unit]
Description="Obsidian Github Sync systemd timer for Mikes Wiki"
Requires=obsidian_github_sync.timer
[Service]
Type=simple
ExecStart=/root/obsidian_gitpush.sh
User=root
obsidian_github_sync.timer:
cat obsidian_github_sync.service
[Unit]
Description="Obsidian Github Sync systemd timer for Mikes Wiki"
Requires=obsidian_github_sync.timer
[Service]
Type=simple
ExecStart=/root/obsidian_gitpush.sh
User=root
root@flanders:/etc/systemd/system# cat obsidian_github_sync.timer
[Unit]
Description="Timer for the obsidian_github_sync.service"
[Timer]
Unit=obsidian_github_sync.service
OnBootSec=5min
OnUnitActiveSec=62min
[Install]
WantedBy=timers.target
I'm running Proxmox 6.8.8-4
I can manually trigger the script and it runs without a problem. However when I enable and start the systemd timer, I get the following message:
$ systemctl status obsidian_github_sync.service
× obsidian_github_sync.service - "Obsidian Github Sync systemd timer for Mikes Wiki"
Loaded: loaded (/etc/systemd/system/obsidian_github_sync.service; static)
Active: failed (Result: exit-code) since Thu 2024-09-05 19:56:57 BST; 11s ago
Duration: 646us
TriggeredBy: ● obsidian_github_sync.timer
Process: 3202705 ExecStart=/root/obsidian_gitpush.sh (code=exited, status=203/EXEC)
Main PID: 3202705 (code=exited, status=203/EXEC)
CPU: 666us
Sep 05 19:56:57 flanders (tpush.sh)[3202705]: obsidian_github_sync.service: Failed to execute /root/obsidian_gitpush.sh: Exec format error
Sep 05 19:56:57 flanders systemd[1]: Started obsidian_github_sync.service - "Obsidian Github Sync systemd timer for Mikes Wiki".
Sep 05 19:56:57 flanders (tpush.sh)[3202705]: obsidian_github_sync.service: Failed at step EXEC spawning /root/obsidian_gitpush.sh: Exec format error
Sep 05 19:56:57 flanders systemd[1]: obsidian_github_sync.service: Main process exited, code=exited, status=203/EXEC
Sep 05 19:56:57 flanders systemd[1]: obsidian_github_sync.service: Failed with result 'exit-code'.
As suggested by @Barmar I just needed to add a shebang at the start of my shell script #!/bin/bash