Bitcoin Forum
May 24, 2022, 03:59:49 PM
Welcome,
Guest
. Please
login
or
register
.
News
: Latest Bitcoin Core release:
23.0
[
Torrent
]
Home
Help
Search
Login
Register
More
Bitcoin Forum
>
Bitcoin
>
Development & Technical Discussion
>
Detect if Bitcoin is running?
Pages: [
1
]
« previous topic
next topic »
Print
Author
Topic: Detect if Bitcoin is running? (Read 2061 times)
Rena
Newbie
Offline
Activity: 19
Merit: 0
Detect if Bitcoin is running?
April 18, 2011, 05:51:58 AM
#1
What would be the proper/best way for a script to tell if bitcoin[d] is running? I'm writing a Lua script that calls `bitcoin getinfo` and similar commands, and I see it outputs a message to stderr if the server isn't running, but Lua doesn't provide any standard way to read stderr, so I was hoping there's another way to check?
1653407989
Hero Member
Offline
Posts: 1653407989
Ignore
1653407989
1653407989
#2
1653407989
Report to moderator
Advertised sites are not
endorsed by the Bitcoin Forum.
They may be unsafe, untrustwo
rthy, or
illegal in your jurisdict
ion.
Adv
ertise he
re.
1653407989
Hero Member
Offline
Posts: 1653407989
Ignore
1653407989
1653407989
#2
1653407989
Report to moderator
1653407989
Hero Member
Offline
Posts: 1653407989
Ignore
1653407989
1653407989
#2
1653407989
Report to moderator
BioMike
Legendary
Offline
Activity: 1658
Merit: 1001
Re: Detect if Bitcoin is running?
April 18, 2011, 05:54:39 AM
#2
# ps|grep bitcoind
That is how I normally do a quick check if services are running.
theymos
Administrator
Legendary
Offline
Activity: 4494
Merit: 9634
Re: Detect if Bitcoin is running?
April 18, 2011, 06:04:14 AM
Last edit: April 18, 2011, 06:15:27 AM by theymos
#3
Code:
if curl -s 127.0.0.1:8332 >/dev/null; then
echo "running"
else
echo "not running"
fi
Edit: Another way (faster):
Code:
if /sbin/ss -l |grep -q "127.0.0.1:8332"; then
echo "running"
else
echo "not running"
fi
1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Rena
Newbie
Offline
Activity: 19
Merit: 0
Re: Detect if Bitcoin is running?
April 18, 2011, 06:27:46 AM
#4
Hmm, both of those rely on Unix shell commands and redirection. I was hoping for something like a PID file I can check that only exists when the server is running. I can do similar just by appending 2>&1 to the command I call from Lua, but as far as I know there's no guarantee that io.popen() will actually execute the command the way a shell would rather than, for example, just passing everything after the first space as the parameter to the program being called.
I can use sockets as well, but that requires adding LuaSocket, and I was hoping not to depend on any external libraries. Lua doesn't provide much on its own (it focuses on being simple and lightweight) so that may prove difficult to avoid...
theymos
Administrator
Legendary
Offline
Activity: 4494
Merit: 9634
Re: Detect if Bitcoin is running?
April 18, 2011, 07:01:29 AM
#5
There is a .lock file in the data directory, though I don't know how reliable this is. Maybe it only appears when Bitcoin is doing something to the database.
You could parse /proc/net/tcp.
1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
genjix
Legendary
Offline
Activity: 1232
Merit: 1050
Re: Detect if Bitcoin is running?
April 18, 2011, 11:26:23 AM
#6
Use my branch and do getinfo
https://github.com/genjix/bitcoin/tree/isinitialized
Rena
Newbie
Offline
Activity: 19
Merit: 0
Re: Detect if Bitcoin is running?
April 19, 2011, 01:51:38 AM
#7
That's the kind of thing I was looking for. Of course that means anyone using my script also has to use that branch. Will that change be in the official client in some future version?
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 1734
Chief Scientist
Re: Detect if Bitcoin is running?
April 19, 2011, 02:05:01 AM
#8
Quote from: Rena on April 18, 2011, 06:27:46 AM
Hmm, both of those rely on Unix shell commands and redirection. I was hoping for something like a PID file..
I pulled a patch that makes Linux/Mac bitcoin/bitcoind write a bitcoind.pid file when started with the -daemon switch (and erases it on shutdown).
Next release will have several changes to make startup on Linux/Mac more unix-standard-like.
How often do you get the chance to work on a potentially world-changing project?
Pages: [
1
]
Print
Bitcoin Forum
>
Bitcoin
>
Development & Technical Discussion
>
Detect if Bitcoin is running?
« previous topic
next topic »
Jump to:
Please select a destination:
-----------------------------
Bitcoin
-----------------------------
=> Bitcoin Discussion
===> Legal
===> Press
===> Meetups
===> Important Announcements
=> Development & Technical Discussion
===> Wallet software
=====> Electrum
=====> Bitcoin Wallet for Android
=====> BitcoinJ
=====> Armory
=====> Mycelium
=====> Hardware wallets
=> Mining
===> Mining support
===> Pools
===> Mining software (miners)
===> Hardware
=====> Group buys
===> Mining speculation
=> Bitcoin Technical Support
=> Project Development
-----------------------------
Economy
-----------------------------
=> Economics
===> Speculation
=> Marketplace
===> Goods
=====> Computer hardware
=====> Digital goods
=======> Invites & Accounts
=====> Collectibles
===> Services
===> Currency exchange
===> Gambling
=====> Games and rounds
=====> Investor-based games
=====> Gambling discussion
===> Lending
=====> Long-term offers
===> Securities
===> Auctions
===> Service Announcements
=====> Micro Earnings
===> Service Discussion
=====> Web Wallets
=====> Exchanges
=> Trading Discussion
===> Scam Accusations
===> Reputation
-----------------------------
Other
-----------------------------
=> Meta
===> New forum software
===> Bitcoin Wiki
=> Politics & Society
=> Beginners & Help
=> Off-topic
=> Serious discussion
===> Ivory Tower
=> Archival
===> Корзина
===> CPU/GPU Bitcoin mining hardware
===> Chinese students
===> Obsolete (buying)
===> Obsolete (selling)
===> MultiBit
-----------------------------
Alternate cryptocurrencies
-----------------------------
=> Altcoin Discussion
=> Announcements (Altcoins)
===> Tokens (Altcoins)
=> Mining (Altcoins)
===> Pools (Altcoins)
=> Marketplace (Altcoins)
===> Service Announcements (Altcoins)
===> Service Discussion (Altcoins)
===> Bounties (Altcoins)
=> Speculation (Altcoins)
-----------------------------
Local
-----------------------------
=> العربية (Arabic)
===> العملات البديلة (Altcoins)
=====> النقاشات
===> إستفسارات و أسئلة المبتدئين
===> التعدين
===> النقاشات الأخرى
===> منصات التبادل
=> Bahasa Indonesia (Indonesian)
===> Jual Beli
===> Mining (Bahasa Indonesia)
===> Altcoins (Bahasa Indonesia)
=> Español (Spanish)
===> Mercado y Economía
=====> Servicios
=====> Trading y especulación
===> Hardware y Minería
===> Esquina Libre
===> Mercadillo
=====> Mexico
=====> Argentina
=====> España
=====> Centroamerica y Caribe
===> Primeros pasos y ayuda
===> Altcoins (criptomonedas alternativas)
=====> Minería de altcoins
=====> Servicios
=====> Tokens (Español)
=> 中文 (Chinese)
===> 跳蚤市场
===> 山寨币
===> 媒体
===> 挖矿
===> 离题万里
=> Hrvatski (Croatian)
===> Trgovina
===> Altcoins (Hrvatski)
=====> Announcements (Hrvatski)
===> Off-topic (Hrvatski)
=> Deutsch (German)
===> Anfänger und Hilfe
===> Mining (Deutsch)
===> Trading und Spekulation
===> Projektentwicklung
===> Off-Topic (Deutsch)
===> Treffen
===> Presse
===> Altcoins (Deutsch)
=====> Announcements (Deutsch)
===> Marktplatz
=====> Auktionen
=====> Suche
=====> Biete
=> Ελληνικά (Greek)
===> Αγορά
===> Mining Discussion (Ελληνικά)
===> Altcoins (Ελληνικά)
=====> Altcoin Announcements (Ελληνικά)
=====> Altcoin Mining (Ελληνικά)
=> עברית (Hebrew)
=> Français
===> Actualité et News
===> Débutants
===> Discussions générales et utilisation du Bitcoin
===> Mining et Hardware
===> Économie et spéculation
===> Place de marché
=====> Échanges
=====> Produits et services
=====> Petites annonces
===> Le Bitcoin et la loi
===> Wiki, documentation et traduction
===> Développement et technique
===> Vos sites et projets
===> Hors-sujet
===> Altcoins (Français)
=====> Annonces
=> India
===> Mining (India)
===> Marketplace (India)
===> Regional Languages (India)
===> Press & News from India
===> Alt Coins (India)
===> Buyer/ Seller Reputations (India)
===> Off-Topic (India)
=> Italiano (Italian)
===> Guide (Italiano)
===> Progetti
===> Discussioni avanzate e sviluppo
===> Trading, analisi e speculazione
===> Mercato
=====> Mercato valute
=====> Beni
=====> Servizi
=====> Esercizi commerciali
=====> Hardware/Mining (Italiano)
=====> Gambling (Italiano)
===> Accuse scam/truffe
===> Mining (Italiano)
===> Alt-Currencies (Italiano)
=====> Annunci
===> Raduni/Meeting (Italiano)
===> Crittografia e decentralizzazione
===> Off-Topic (Italiano)
=> 日本語 (Japanese)
===> アルトコイン
=> Nederlands (Dutch)
===> Markt
===> Gokken/lotterijen
===> Mining (Nederlands)
===> Beurzen
===> Alt Coins (Nederlands)
===> Off-topic (Nederlands)
===> Meetings (Nederlands)
=> 한국어 (Korean)
===> 대체코인 Alt Coins (한국어)
=> Pilipinas
===> Altcoins (Pilipinas)
=====> Altcoin Announcements (Pilipinas)
===> Pamilihan
===> Others (Pilipinas)
=> Polski
===> Tablica ogłoszeń
===> Alternatywne kryptowaluty
=====> Nowe kryptowaluty i tokeny
=====> Tablica ogłoszeń (altcoiny)
=> Português (Portuguese)
===> Primeiros Passos (Iniciantes)
===> Economia & Mercado
===> Mineração em Geral
===> Desenvolvimento & Discussões Técnicas
===> Criptomoedas Alternativas
===> Brasil
===> Portugal
=> Русский (Russian)
===> Новички
===> Бизнес
=====> Барахолка
=====> Обменники
===> Идеи
===> Кодеры
===> Майнеры
===> Политика
===> Трейдеры
===> Альтернативные криптовалюты
=====> Токены
=====> Бayнти и aиpдpoпы
===> Хайпы
===> Работа
===> Разное
===> Oбcyждeниe Bitcoin
=====> Новости
=====> Юристы
=> Română (Romanian)
===> Anunturi importante
===> Offtopic
===> Market
=====> Discutii Servicii
===> Minerit
===> Tutoriale
===> Bine ai venit!
===> Presa
===> Altcoins (Monede Alternative)
=====> Anunturi Monede Alternative
=> Skandinavisk
=> Türkçe (Turkish)
===> Bitcoin Haberleri
===> Pazar Alanı
===> Madencilik
===> Ekonomi
===> Servisler
=====> Fonlar
===> Proje Geliştirme
===> Alternatif Kripto-Paralar
=====> Madencilik (Alternatif Kripto-Paralar)
=====> Duyurular (Alternatif Kripto-Paralar)
===> Konu Dışı
===> Yeni Başlayanlar & Yardım
===> Buluşmalar
=> Other languages/locations
Loading...