1
votes

im working on getting my roku tv to turn on when the pc boots up for a gaming console. i can get this comnad to run and works great manually. but need it to run when the pc boots up and thats the only time. just once. Total ubuntu newbie here. so if you could kind give me the walk thru version lol. thank you to whoever fixes my 5 day headache!

here is the command

curl -d '' http://192.168.1.137:8060/keypress/PowerOn

just need it to run on bootup!

3
This kind of basic question has been answered many times on this site (and others). Please search for existing solutions before creating a new question. (in your case search for something like "ubuntu/linux run script on startup"). - Maurice Schleußinger

3 Answers

1
votes

You'll want to use a systemd unit.

$ sudo nano /etc/systemd/system/wakeTV.service

Paste this into the file

[Unit]
Description=Wake TV on boot
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/curl http://192.168.1.137:8060/keypress/PowerOn

[Install]
WantedBy=multi-user.target

Then, enable this unit at startup

$ sudo systemctl enable wakeTV.service

Now, it should run at boot. To diagnose errors, use systemctl status wakeTV

0
votes

A cron job to run the command at boot.

A command:

@reboot command arg1 arg2 ... argn

A script:

@reboot script.sh

In your case run crontab -e then add the following line:

@reboot /usr/bin/curl -d '' http://192.168.1.137:8060/keypress/PowerOn

Help Ubuntu: CronHowto-Crontab Lines

0
votes

I was working with Raspberry Pi, trying to make a service that reports via web upon boot. For me things like

Wants=network-online.target
After=network-online.target NetworkManager.service network.target systemd-networkd.service

did nothing. Crontab also fails, of course. At least if you're on wifi then for certain. This is what I ended up using with actual success:

[Unit]
Description=Service name


[Service]
Restart=on-failure
RestartSec=10s
ExecStart=/usr/bin/curl parameters for curl


[Install]
WantedBy=multi-user.target