Hi everyone. I'm starting with debian, my linux knowledge is very little.
I'm trying to get a Bitcoin full-node up un running. Actually I already did and everything is working as expected.
I was wondering which is the simplest but recommended method to run something at startup, and I'll describe you what I read.
1) crontab: it seem pretty simple just adding a line @reboot bitcoind -daemon, but I read that @reboot only executes on actual reboots and not after system halted, that's not what I'm looking for.
2) edit /etc/rc.local: I wasn't able to find this in my debian stretch, I read that it was replaced with systemd or something? (remember, beginner here)
so, what is a simple way to run something at startup?
The idea is that bitcoin daemon run even BEFORE any user autenticates on every startup for whatever reason.
Sorry for my non-native english and thanks in advance for your advices.
edit: it should be BEFORE, not after any user logins.
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
simplest/recommended way to run something at startup
simplest/recommended way to run something at startup
Last edited by alete on 2017-06-12 11:26, edited 1 time in total.
Re: simplest/recommended way to run something at startup
Does that mean after user has logged in from the "graphical login screen" into the desktop on system startup, not after unlocking the screen or switch user?alete wrote:The idea is that bitcoin daemon run even after any user autenticates on every startup for whatever reason
If so:
If you are running Bitcoin Core GUI, then you can configure autostart behaviour in the Bitcoin Core GUI options.
If you only have Bitcoin Core Daemon, then the easiest way to run it as the regular user is to add the startup command to your desktop environment's "Startup Applications" config tool such as this and this.
Systemd still provides rc-local.service. The content of /etc/rc.local will be executed towards the end of multi-user.target if /etc/rc.local is marked executable. But you might not want this since (1) By default it execute commands as root; (2) It will be executed before user has logged in.alete wrote: edit /etc/rc.local: I wasn't able to find this in my debian stretch, I read that it was replaced with systemd or something
Re: simplest/recommended way to run something at startup
A Systemd service file is easy to make, is very flexible and works/debugging easy. But if you require a desktop and a graphical instance of a programming then you should use your DE's autostart.
Re: simplest/recommended way to run something at startup
I'm sorry, I just edited the original post.
I mixed 'before' and 'after' somehow.
I'm trying to run bitcoind -daemon (without GUI) BEFORE any user logins. I'm running debian in my LattePanda which is a mini-pc like raspberry-pi but with an intel x64(x86) processor, and it is headless, I only access through SSH.
So I guess that I'll look for a way to start it with systemd like you suggested.
Thank you both.
I mixed 'before' and 'after' somehow.
I'm trying to run bitcoind -daemon (without GUI) BEFORE any user logins. I'm running debian in my LattePanda which is a mini-pc like raspberry-pi but with an intel x64(x86) processor, and it is headless, I only access through SSH.
So I guess that I'll look for a way to start it with systemd like you suggested.
Thank you both.
Re: simplest/recommended way to run something at startup
Hi, Obviously I got troubles with this.
this my bitcoind.service
then I:
systemctl enable bitcoind.service
then I sudo shutdown -r and nothing changed :s
Any advice? Thank you guys.
this my bitcoind.service
Code: Select all
[Unit]
Description=Bitcoin Daemon Service
[Service]
ExecStart=/usr/local/bin/bitcoind -daemon -datadir=/media/alete/SD/bitcoinData #I tried with ExecStart=bitcoind -daemon ...
[Install]
WantedBy=multi-user.target
systemctl enable bitcoind.service
then I sudo shutdown -r and nothing changed :s
Any advice? Thank you guys.
Re: simplest/recommended way to run something at startup
You may want to add more configuration into the unit file. Start with skimming through `man systemd.service`.
1. When you execute `bitcoind -daemon` in a terminal, does it immediately returns you to the command prompt? Can you close the terminal and bitcoind would still be running in background?
If so, consider adding `Type=forking` to [Service]
2. Daemonized process usually use some pidfile to identify the main process, e.g. it could be located in /var/run or any other self-defined location.
Locate the pidfile and add `PIDFile=</path/to/pidfile>` to [Service]
3. Does bidcoind requires internet connection?
If so, consider adding `After=network.target` to [Unit]
4. You might not want to run bitcoind as root due to safety concerns.
If so, consider configuring "User" and "Group" in [Service]
Consult http://freedesktop.org/wiki/Software/systemd/Debugging/ if you would like to investigate the situation further.
You could always revert to /etc/rc.local if you couldn't make the systemd unit work.
1. When you execute `bitcoind -daemon` in a terminal, does it immediately returns you to the command prompt? Can you close the terminal and bitcoind would still be running in background?
If so, consider adding `Type=forking` to [Service]
2. Daemonized process usually use some pidfile to identify the main process, e.g. it could be located in /var/run or any other self-defined location.
Locate the pidfile and add `PIDFile=</path/to/pidfile>` to [Service]
3. Does bidcoind requires internet connection?
If so, consider adding `After=network.target` to [Unit]
4. You might not want to run bitcoind as root due to safety concerns.
If so, consider configuring "User" and "Group" in [Service]
Consult http://freedesktop.org/wiki/Software/systemd/Debugging/ if you would like to investigate the situation further.
You could always revert to /etc/rc.local if you couldn't make the systemd unit work.
Re: simplest/recommended way to run something at startup
Oh, it seems that Bitcoin Core has already provided an "official" systemd unit file.
https://github.com/bitcoin/bitcoin/blob ... nd.service
Ignore me.
https://github.com/bitcoin/bitcoin/blob ... nd.service
Ignore me.
Re: simplest/recommended way to run something at startup
that was a good call!orythem27 wrote:Oh, it seems that Bitcoin Core has already provided an "official" systemd unit file.
https://github.com/bitcoin/bitcoin/blob ... nd.service
Ignore me.
Thank you