Startup daemon

Hi, I’m looking for a way to use Aria2 daemon (runlevel 5) when osmc start but it seems than update-rc.d doesn’t work…
Sorry for my english, I speak french

Use systemd unit instead.

Thank you, I’m not abble to do this

Try this. I assume you can edit files in Linux.

  1. In directory /lib/systemd/system create a file (using sudo) called aria2.service :

Description=Aria2 a lightweight multi-protocol & multi-source command-line download utility

ExecStart=/usr/bin/aria2 -D # You will need to find the correct name yourself
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID


2 Run sudo systemctl enable aria2
3 Run sudo systemctl start aria2

No guarantees! :wink:

Edit: It looks like you need the -D flag to run aria2 as a daemon, so I’ve adjusted the code above.

Thank you, yes I can edit files, I’ll try your method but right now I’m writing the .img on the Rpi.

In the /usr/bin folder is aria2c so I’ll change the code to :


but, -D is for deamon ? Where can I find the correct name ?

Manualy I can start aria2 with :

aria2c --enable-rpc --rpc-listen-all --daemon

I found something like this :


If you want aria to start when the operating system starts, it will normally be run as a daemon.

See aria2c(1) — aria2 1.35.0 documentation

As you can see -D is the same as --daemon so either is correct. You’ll need to experiment with the ExecStart line.

Unfortunately, it doesn’t works. To resume the steps :

Lighttpd :

cd /var/www/
sudo rm -r html
sudo rm index.html
sudo git clone html

Aria2 :

sudo -s
apt-get install aria2


cd /lib/systemd/system
touch aria2.service
nano aria2.service



ExecStart=/usr/bin/aria2c --enable-rpc --rpc-listen-all -D
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID


after this :

systemctl enable aria2
systemctl start aria2

While I do like to help out, I know nothing about aria - and this is, after all, an OSMC forum, not an aria forum.

First, you need to see if the aria daemon is running, using the command systemctl status aria2 . Then, if running, stop it with sudo systemctl stop aria2 and amend the ExecStart line in aria2.service using the parameters from the link in your post. Experiment by adding and removing options.

Then run

sudo systemctl daemon-reload
sudo systemctl start aria2

Unfortunately, I am unable to help you with any problems beyond getting aria to start.

Thank you even if you are unable to help me with this problem :slight_smile:
I try to add and remove but it still doesn’t work … Maybe I’ll found the right way in a aria forum …

What was the result of systemctl status aria2 ?

Started aria2

That didn’t start correctly.

Have a look at this [Solved] SystemD, aria2 as a daemon (not smartly) / System Administration / Arch Linux Forums

I have seen this before :worried:

My solution is :

cd /home/omsc/
mkdir scripts
cd /scripts

aria2c --enable-rpc --rpc-listen-all --daemon

sudo chmod +x
sudo chmod 777 #777 is for the test

cd /etc/init.d/

sudo touch
sudo chmod 777 aria2c
sudo chmod +x aria2c

set -e

case “${1:-}” in

  /home/osmc/scripts/ ;;
  	echo "Usage: ${0:-} {start}" >&2
  	exit 1

Manualy I start aria2 with

/etc/init.d/aria2c start

I try to use cron to start it at the boot

crontab -e

@reboot sh /home/osmc/scripts/

This works for me:




Type=forking is the key.

Excellent info! Did you find this somewhere or was it a matter of trial and error?

One observation. For security reasons, you might try running it with User=nobody, since it’s an internet-facing application. (I’m not saying it’ll work as nobody, but if it does it offers an additional level of protection.)

Good news ! I have an other solution :
edit : for me it dosen’t works :frowning:

Make a service in etc/init.d/aria2

#! /bin/sh
# /etc/init.d/aria2
# Provides: aria2cRPC
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c RPC init script.
# Description: Starts and stops aria2 RPC services.
case "$1" in
 echo -n "Starting aria2c daemon: "
 umask 0000
 aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2.conf
 umask 0000
 aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2.conf
 echo -n "Shutting down aria2c daemon: "
 /usr/bin/killall aria2c
 sleep 3
 echo $"Usage: $0 {start|stop|restart}"
exit $RETVAL

sudo chmod +x aria2
sudo chmod 777 aria2

sudo /etc/init.d/aria2 start #(manualy it works fine)

sudo update-rc.d aria2 defaults #help-and-support (it doesn’t work for now)

it works for me
follow 4 steps:

sudo chmod 755 /etc/init.d/aria2
sudo chmod +x /etc/init.d/aria2
update-rc.d aria2 defaults

Where possible you should use the systemd service definition in the post by @rern on April 1st rather than the deprecated init.d method.