linux - Trigger CURL Request after boot using systemd -


i'm trying create service trigger every time raspberry pi boots. service runs simple script sends post request web service endpoint control. can trigger said script manually , part works perfectly.

i'm struggling next step script run after pi has finished booting. need able run without user logging in.

curl script (algiers-startup.local)

#! /bin/bash  echo "attempting curl request" curl --data "param1=value1&param2=value2" http://10.68.159.28:3000/device 

systemd service

[unit] description=algiers raspberrypi startup after=network.target before=getty@tty1.service  [service] type=oneshot execstart=/usr/local/sbin/algiers-startup.local timeoutsec=30 standardoutput=tty remainafterexit=no  [install] wantedby=multi-user.target 

i see no errors or outputs in console, no hint has happened @ all.

i’ll assume machine set systemd. it’s controlled through systemctl command. alias such since it’s awful type time:

alias sc=systemctl alias ssc='sudo systemctl' 

you need “enable” service have run @ boot:

sc enable algiers-startup 

i’m not sure distro you’re using, on arch , centos, you’ll want algiers-startup live down in /usr/lib/systemd/system/.

you can test service sc start algiers-start. journalctl can show what’s happening.


Comments