Init
Introduction
The linux kernel starts the initialization process immediately after the booting process. Since the Linux kernel uses process ID 0 to refer to itself, it assigns the process ID 1 to the initialization process.
Once started, the initialization process takes control of bringing the system up. It reads the configuration file and based on the configured state in the configuration file it starts all other services and processes.
The initialization process is the parent of all processes and you can determine the flavour from the process name for process one by executing:
pstree -Ap
and observe the hierachy.
sysV
SystemV is the original posix system initialization process from the Unix precursors and early Linux systems, it has been superceded by systemd and upstart, but mat still exist in legacy systems.
For further information see https://wiki.archlinux.org/index.php/SysVinit
- the view of the init tree execute:
pstree -Ap
init(1)-+-acpid(3432)
|-crond(3423)
|-dbus-daemon(3469)
|-gpm(3485)
|-mylogin(3536)
|-ngetty(3535)---login(3954)---zsh(4043)---pstree(4326)
|-polkitd(4033)---{polkitd}(4035)
|-syslog-ng(3413)---syslog-ng(3414)
`-udevd(643)-+-udevd(3194)
`-udevd(3218)
Besides usual initialization of system (as the name suggests), init also handles rebooting, shutdown and booting into recovery mode (single-user mode). To support these, inittab groups entries into different runlevels. The runlevels Arch uses are 0 for halt, 1 (aliased as S) for single-user mode, 3 for normal booting (multi-user mode), 5 for X and 6 for reboot. Other distros may adopt other conventions, but the meanings of 0, 1 and 6 are universal.
Upon execution, init scans inittab and carry out appropriate actions. An entry in inittab takes the form
id:runlevels:action:process
Where id is a unique identifier for the entry (just a name, no real impact on init), and runlevels is a (not delimited) string of runlevels. If the runlevel init is entering appears in runlevels, action is carried out, executing process if appropriate. Some special actions would cause init to ignore runlevels and adopt a special matching method. More explanation follows in the next section.
See also man 5 inittab and man 8 init.
upstart
The Upstart was created as a replacement for the SysVinit model. Unlike SysVinit which had created to operate in a static environment, the Upstart was created to operate in a flexible environment.
The Upstart provides three major benefits over the SysVinit. These benefits are; event-based service management, asynchronous services startup, and automatic restart of crashed services.
The Upstart, instead of using run-levels, uses system events to start and stop services. An event is a change in the system state. When an event occurs, the upstart detects that event and makes necessary changes.
An event can be anything that requires or triggers a change in the system state. The following are a few examples of events.
- A hot-plug device (such as USB drive) is plugged-in or removed from the system.
- The system boots up.
- A service is started or stopped.
The Upstart was developed as a replacement of SysVinit, not as a modern system initializer program. Upstart fully addressed all of SysVinit's shortcomings, but missed out on new features. Until a modern initializer program has been developed, to overcome the limitations of SysVinit, the Upstart was used as a temporary solution by many Linux developers. RedHat also used the Upstart in RHEL6.
Observations on my arising-san synology NAS:
pstree -ap
init,1
├─Plex Media Serv,14944
│ ├─Plex Script Hos,15148 /volume1/@appstore/Plex Media Server/Resources/Plug-ins-f5213a238/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.18.5.2309-f5213a238/volume1/@appstore/Plex M
│ │ ├─{Plex Script Hos},15468
│ │ ├─{Plex Script Hos},15469
│ │ ├─{Plex Script Hos},15470
│ │ ├─{Plex Script Hos},15471
│ │ ├─{Plex Script Hos},15472
│ │ ├─{Plex Script Hos},15473
│ │ ├─{Plex Script Hos},15474
│ │ ├─{Plex Script Hos},15475
│ │ ├─{Plex Script Hos},15725
│ │ ├─{Plex Script Hos},15726
│ │ ├─{Plex Script Hos},15741
│ │ └─{Plex Script Hos},30939
│ ├─Plex Tuner Serv,15775 /volume1/@appstore/Plex Media Server/Resources/Tuner/Private /volume1/@appstore/Plex Media Server/Resources/Tuner/Shared 1.18.5.2309-f5213a238 32600 /waitmutex
│ │ ├─{Plex Tuner Serv},15814
│ │ ├─{Plex Tuner Serv},15818
│ │ ├─{Plex Tuner Serv},15819
│ │ ├─{Plex Tuner Serv},15820
│ │ ├─{Plex Tuner Serv},15821
│ │ ├─{Plex Tuner Serv},15822
│ │ ├─{Plex Tuner Serv},15823
│ │ ├─{Plex Tuner Serv},15824
│ │ ├─{Plex Tuner Serv},15825
│ │ ├─{Plex Tuner Serv},15826
│ │ ├─{Plex Tuner Serv},16157
│ │ └─{Plex Tuner Serv},16158
│ ├─{Plex Media Serv},15079
│ ├─{Plex Media Serv},15084
│ ├─{Plex Media Serv},15085
│ ├─{Plex Media Serv},15128
│ ├─{Plex Media Serv},15129
│ ├─{Plex Media Serv},15131
│ ├─{Plex Media Serv},15132
│ ├─{Plex Media Serv},15134
│ ├─{Plex Media Serv},15136
│ ├─{Plex Media Serv},15147
│ ├─{Plex Media Serv},15744
│ ├─{Plex Media Serv},15769
│ ├─{Plex Media Serv},15771
│ ├─{Plex Media Serv},15772
│ ├─{Plex Media Serv},15773
│ ├─{Plex Media Serv},15794
│ ├─{Plex Media Serv},15796
│ ├─{Plex Media Serv},15798
│ ├─{Plex Media Serv},15803
│ ├─{Plex Media Serv},16178
│ ├─{Plex Media Serv},16597
│ ├─{Plex Media Serv},16599
│ ├─{Plex Media Serv},16606
│ ├─{Plex Media Serv},16607
│ └─{Plex Media Serv},21808
├─avahi-daemon,16377
├─cgmanager,4183 --sigstop
├─cloud-authd,15304
├─cloud-cached,15119
│ ├─{cloud-cached},15120
│ ├─{cloud-cached},15121
│ ├─{cloud-cached},15122
│ └─{cloud-cached},15123
├─cloud-cleand,15356
│ ├─{cloud-cleand},15358
│ └─{cloud-cleand},15360
├─crond,13942
├─dbus-daemon,4990 --system --nopidfile
├─dbus-daemon,4993 --session --fork --print-address
├─dhclient,8167 -4 -d -q -lf /tmp/dhcpv4.leases.bond0 -pf /tmp/dhcpcd-bond0.pid -sf /var/run/dhclient-script bond0
├─dhclient,8444 -4 -d -q -lf /tmp/dhcpv4.leases.bond1 -pf /tmp/dhcpcd-bond1.pid -sf /var/run/dhclient-script bond1
├─findhostd,9868
├─getty,10895 115200 console
├─hotplugd,12629
├─idmapd,13048
├─img_backupd,14718
├─iscsi_snapshot_,10692 -D
│ ├─{iscsi_snapshot_},11192
│ └─{iscsi_snapshot_},11193
├─iscsi_snapshot_,10703 -D
├─minissdpd,9875 -i bond0 -i bond1
├─mountd,12823 -p 892
├─nginx,13199
│ ├─nginx,16384
│ ├─nginx,16385
│ ├─nginx,16386
│ └─nginx,16387
├─nmbd,16303 -F
├─node,9714 /volume1/stats/server1.js
│ ├─{node},9870
│ ├─{node},9871
│ ├─{node},9872
│ ├─{node},9873
│ ├─{node},9874
│ ├─{node},9887
│ ├─{node},11079
│ ├─{node},11080
│ ├─{node},11081
│ └─{node},11082
├─node,15460 /var/packages/SynologyApplicationService/target/node_libs/VapidSendServer.js
│ ├─{node},15462
│ ├─{node},15463
│ ├─{node},15464
│ ├─{node},15465
│ ├─{node},15466
│ └─{node},15467
├─notification_se,15124
├─npm,15712
│ ├─node,15916 msg_server.js
│ │ ├─{node},15918
│ │ ├─{node},15919
│ │ ├─{node},15920
│ │ ├─{node},15921
│ │ └─{node},15922
│ ├─{node},15751
│ ├─{node},15752
│ ├─{node},15753
│ ├─{node},15754
│ ├─{node},15763
│ ├─{npm},15892
│ ├─{npm},15893
│ ├─{npm},15894
│ └─{npm},15895
├─ntpd,9864 -p /var/run/ntpd.pid -g -u ntp:ntp
│ └─{ntpd},9886
├─pgbouncer,15671 -q /var/packages/Chat/target/etc/pgbouncer.ini
├─pgbouncer,15333 -q /var/packages/SynologyApplicationService/target/etc/pgbouncer.ini
├─php56-fpm,14874
├─postgres,12812 -D /var/services/pgsql
│ ├─postgres,13195
│ ├─postgres,13196
│ └─postgres,13197
├─rpcbind,12809
├─s2s_daemon,10278 -d
├─scemd,13875
│ ├─{scemd},13883
│ ├─{scemd},14714
│ ├─{scemd},14715
│ ├─{scemd},14716
│ └─{scemd},14717
├─scsi_plugin_ser,10694
│ ├─{default-executo},10972
│ ├─{grpc_global_tim},10974
│ ├─{grpcpp_sync_ser},10975
│ └─{resolver-execut},10973
├─session_watcher,15517
├─session_watcher,15518
│ ├─{session_watcher},15519
│ ├─{session_watcher},15521
│ ├─{session_watcher},15522
│ ├─{session_watcher},15523
│ ├─{session_watcher},15683
│ ├─{session_watcher},15684
│ ├─{session_watcher},15685
│ ├─{session_watcher},15686
│ ├─{session_watcher},15687
│ ├─{session_watcher},15688
│ ├─{session_watcher},15689
│ └─{session_watcher},15690
├─smbd,13055 -F
│ ├─cleanupd,13483 -F
│ └─smbd-notifyd,13482 -F
├─snmpd,9906 -fLn -c /etc/snmp/snmpd.conf -p /var/run/snmpd.pid 127.0.0.1:161
├─sshd,9859
│ └─sshd,13662
│ └─sshd,13771
│ └─sh,13774
│ └─pstree,13841 -ap
├─statd,13093
├─sudo,12462 -u nobody /usr/syno/bin/synowstransferd
│ └─synowstransferd,12699
├─sudo,12763 -u nobody /usr/syno/bin/synowsdiscoveryd
│ └─synowsdiscovery,12807 /usr/syno/bin/synowsdiscoveryd
│ ├─{synowsdiscovery},13212
│ └─{synowsdiscovery},13222
├─syncd,15421
│ ├─syncd,15423
│ │ ├─{syncd},15424
│ │ ├─{syncd},15425
│ │ ├─{syncd},15426
│ │ ├─{syncd},15427
│ │ ├─{syncd},15428
│ │ ├─{syncd},15429
│ │ ├─{syncd},15430
│ │ ├─{syncd},15431
│ │ ├─{syncd},15432
│ │ ├─{syncd},15433
│ │ ├─{syncd},15434
│ │ ├─{syncd},15435
│ │ ├─{syncd},15436
│ │ ├─{syncd},15437
│ │ └─{syncd},15438
│ └─syncd,15440
│ ├─{syncd},15441
│ ├─{syncd},15442
│ ├─{syncd},15443
│ ├─{syncd},15444
│ ├─{syncd},15445
│ └─{syncd},15446
├─syno-cloud-clie,15392
│ ├─{syno-cloud-clie},15398
│ ├─{syno-cloud-clie},15399
│ ├─{syno-cloud-clie},15400
│ └─{syno-cloud-clie},15401
├─synoagentregist,9735
├─synobackupd,12380
├─synocachepinfil,9966 --start-service --config-path /usr/syno/etc/flashcache_pin_file.conf
│ └─{synocachepinfil},9983
├─synocgid,12498 -D
├─synochatcrond,16151
├─synochatd,15990 -i 8
│ ├─synochatd,16041 -i 8
│ ├─synochatd,16042 -i 8
│ ├─synochatd,16047 -i 8
│ ├─synochatd,16048 -i 8
│ ├─synochatd,16049 -i 8
│ ├─synochatd,16050 -i 8
│ ├─synochatd,16051 -i 8
│ ├─synochatd,16052 -i 8
│ ├─{synochatd},16036
│ └─{synochatd},16037
├─synoconfd,5080 -D
│ └─{gdbus},5083
├─synocrond,9998
├─synodisklatency,13848
├─synoelasticd,15240
│ ├─{synoelasticd},15316
│ ├─{synoelasticd},15317
│ ├─{synoelasticd},15318
│ ├─{synoelasticd},15320
│ ├─{synoelasticd},15321
│ ├─{synoelasticd},15322
│ ├─{synoelasticd},15323
│ ├─{synoelasticd},15324
│ ├─{synoelasticd},15325
│ ├─{synoelasticd},15326
│ ├─{synoelasticd},15327
│ ├─{synoelasticd},15328
│ ├─{synoelasticd},15329
│ ├─{synoelasticd},15330
│ └─{synoelasticd},15331
├─synologaccd,4939 -f
├─synologand,9980
│ ├─{synologand},10058
│ ├─{synologand},10065
│ └─{synologand},10068
├─synologrotated,4908
├─synonetd,5130
│ ├─{synonetd},5277
│ └─{synonetd},5278
├─synorelayd,13873
│ ├─{synorelayd},14264
│ ├─{synorelayd},14266
│ └─{synorelayd},14267
├─synoscgi_______,9818
│ ├─(SYNO.Core.UserS,21919)
│ ├─synoscgi_______,9905
│ ├─synoscgi_______,9907
│ ├─synoscgi_______,15157
│ ├─synoscgi_______,21734
│ └─synoscgi_______,21927
├─synoscgi_______,16121 --mode=apid --conf=/var/packages/Chat/target/etc/synoapid.json
│ ├─SYNO.Chat.Admin,16124 --mode=apid --conf=/var/packages/Chat/target/etc/synoapid.json
│ ├─synoscgi_______,16126 --mode=apid --conf=/var/packages/Chat/target/etc/synoapid.json
│ ├─{synoscgi_______},16123
│ └─{synoscgi_______},16127
├─synosnmpcd,9985
├─synostoraged,10057
│ ├─synostoraged,10059
│ ├─synostoraged,10060
│ └─synostoraged,10061
├─synotifyd,12432
│ ├─{synotifyd},12488
│ └─{synotifyd},12489
├─syslog-ng,4261 -F --worker-threads=4 -u system -g log
│ ├─{syslog-ng},5182
│ ├─{syslog-ng},5183
│ ├─{syslog-ng},5184
│ ├─{syslog-ng},5185
│ ├─{syslog-ng},5186
│ ├─{syslog-ng},5187
│ ├─{syslog-ng},5188
│ ├─{syslog-ng},5189
│ ├─{syslog-ng},5190
│ ├─{syslog-ng},5191
│ ├─{syslog-ng},5192
│ ├─{syslog-ng},5193
│ ├─{syslog-ng},5194
│ └─{syslog-ng},13700
├─thumbd,15139
│ ├─thumbd,15141
│ ├─thumbd,15142
│ ├─thumbd,15501
│ ├─thumbd,15502
│ ├─thumbd,15503
│ ├─thumbd,15504
│ ├─thumbd,15505
│ ├─thumbd,15506
│ ├─thumbd,15507
│ ├─thumbd,15508
│ ├─{thumbd},15140
│ └─{thumbd},15143
├─udevd,5305 --daemon
├─vmtouch,10891 -lfd /var/run
└─vmtouch,14606 -l /usr/syno/bin/synoschedtask /usr/syno/bin/synoschedtool /usr/syno/etc/scheduled_tasks
systemd
The Systemd is the modern system initializer program. Most Linux developers including RedHat (from version 7) and Ubuntu (from version 15.04) use systemd as the default system initializer program.
Unlike its predecessors, the systemd is not as easy to understand.
To meet with modern system requirements, it contains several features and tools. These features and tools allow you to manage services, devices, sockets, mount points, swap area, unit types, targets, and many mores. Advantages of the Systemd are the following.
- It starts services in parallel mode.
- It automatically resolves dependencies.
- It can repawn processes.
- It can track and relate processes together by using Linux control groups.
- It has been created to operate in the flexible modern environment. It means, it supports all types of modern hardware such as hot-plug devices and large data storages.
- It can start daemons on-demand without restarting the running service.
- It can create span-shot of the running system state.
- It can log events.
The following is from my Debian host:
systemd(1)-+-ModemManager(872)-+-{ModemManager}(904)
| `-{ModemManager}(915)
|-NetworkManager(878)-+-dhclient(29296)
| |-dhclient(29304)
| |-{NetworkManager}(913)
| `-{NetworkManager}(918)
|-accounts-daemon(876)-+-{accounts-daemon}(902)
| `-{accounts-daemon}(916)
|-agent(2658)-+-{agent}(2660)
| `-{agent}(2662)
|-agetty(1560)
|-alsactl(871)
|-apache2(1565)-+-apache2(29282)
| |-apache2(29283)
| |-apache2(29284)
| |-apache2(29285)
| `-apache2(29286)
|-avahi-daemon(881)---avahi-daemon(922)
|-blkmapd(433)
|-blueman-applet(2672)-+-{blueman-applet}(2834)
| |-{blueman-applet}(2835)
| `-{blueman-applet}(2836)
|-bluetoothd(880)
|-chronyd(944)---chronyd(951)
|-clipit(2670)-+-{clipit}(2694)
| `-{clipit}(2695)
|-colord(929)-+-{colord}(948)
| `-{colord}(950)
|-cron(1275)
|-cups-browsed(29288)-+-{cups-browsed}(29310)
| `-{cups-browsed}(29311)
|-cupsd(29287)
|-dbus-daemon(877)
|-dnsmasq(1693)---dnsmasq(1694)
|-dnsmasq(1722)---dnsmasq(1723)
|-dnsmasq(1800)---dnsmasq(1801)
|-dnsmasq(1828)---dnsmasq(1829)
|-dnsmasq(1981)---dnsmasq(1982)
|-dnsmasq(2154)---dnsmasq(2155)
|-dnsmasq(2206)---dnsmasq(2207)
|-dnsmasq(2272)---dnsmasq(2273)
|-exim4(2301)
|-gnome-keyring-d(2568)-+-{gnome-keyring-d}(2569)
| |-{gnome-keyring-d}(2570)
| `-{gnome-keyring-d}(3039)
|-irqbalance(901)---{irqbalance}(907)
|-libvirtd(1273)-+-{libvirtd}(1475)
| |-{libvirtd}(1476)
| |-{libvirtd}(1477)
| |-{libvirtd}(1478)
| |-{libvirtd}(1479)
| |-{libvirtd}(1480)
| |-{libvirtd}(1481)
| |-{libvirtd}(1482)
| |-{libvirtd}(1483)
| |-{libvirtd}(1484)
| |-{libvirtd}(1566)
| |-{libvirtd}(1567)
| |-{libvirtd}(1568)
| |-{libvirtd}(1569)
| |-{libvirtd}(1570)
| |-{libvirtd}(1595)
| `-{libvirtd}(4425)
|-lightdm(1296)-+-Xorg(1561)-+-{Xorg}(1591)
| | |-{Xorg}(1592)
| | `-{Xorg}(1609)
| |-lightdm(2550)-+-x-session-manag(2571)-+-lxpanel(26+
| | | |-lxpolkit(2+
| | | |-openbox(26+
| | | |-pcmanfm(26+
| | | |-ssh-agent(+
| | | |-xscreensav+
| | | |-{x-session+
| | | `-{x-session+
| | |-{lightdm}(2551)
| | `-{lightdm}(2552)
| |-{lightdm}(1347)
| `-{lightdm}(1350)
|-menu-cached(2744)-+-{menu-cached}(2774)
| `-{menu-cached}(2775)
|-mount.ntfs(3121)
|-nm-applet(2653)-+-{nm-applet}(2674)
| |-{nm-applet}(2675)
| `-{nm-applet}(2699)
|-polkitd(925)-+-{polkitd}(930)
| `-{polkitd}(932)
|-qemu-system-x86(2360)-+-{qemu-system-x86}(2370)
| |-{qemu-system-x86}(2374)
| |-{qemu-system-x86}(2375)
| |-{qemu-system-x86}(2376)
| |-{qemu-system-x86}(2377)
| |-{qemu-system-x86}(2378)
| |-{qemu-system-x86}(2379)
| |-{qemu-system-x86}(2380)
| |-{qemu-system-x86}(2381)
| |-{qemu-system-x86}(2383)
| |-{qemu-system-x86}(5114)
| `-{qemu-system-x86}(5115)
|-qemu-system-x86(2501)-+-{qemu-system-x86}(2503)
| |-{qemu-system-x86}(2508)
| |-{qemu-system-x86}(2509)
| |-{qemu-system-x86}(2510)
| |-{qemu-system-x86}(2511)
| |-{qemu-system-x86}(2512)
| |-{qemu-system-x86}(2513)
| |-{qemu-system-x86}(2515)
| |-{qemu-system-x86}(5105)
| |-{qemu-system-x86}(5106)
| |-{qemu-system-x86}(5107)
| |-{qemu-system-x86}(5108)
| |-{qemu-system-x86}(5109)
| |-{qemu-system-x86}(5110)
| `-{qemu-system-x86}(5111)
|-qemu-system-x86(11646)-+-{qemu-system-x86}(11661)
| |-{qemu-system-x86}(11664)
| |-{qemu-system-x86}(11665)
| |-{qemu-system-x86}(11666)
| |-{qemu-system-x86}(11667)
| |-{qemu-system-x86}(11668)
| |-{qemu-system-x86}(11670)
| |-{qemu-system-x86}(11671)
| |-{qemu-system-x86}(11673)
| |-{qemu-system-x86}(11676)
| `-{qemu-system-x86}(5104)
|-rpc.idmapd(23250)
|-rpc.mountd(23251)
|-rpcbind(816)
|-rsyslogd(873)-+-{rsyslogd}(910)
| |-{rsyslogd}(911)
| `-{rsyslogd}(912)
|-rtkit-daemon(875)-+-{rtkit-daemon}(919)
| `-{rtkit-daemon}(920)
|-smartd(899)
|-ssh-agent(2643)
|-sshd(946)
|-systemd(2555)-+-(sd-pam)(2556)
| |-at-spi-bus-laun(2602)-+-dbus-daemon(2607)
| | |-{at-spi-bus-laun}(2603)
| | |-{at-spi-bus-laun}(2604)
| | `-{at-spi-bus-laun}(2606)
| |-at-spi2-registr(2609)-+-{at-spi2-registr}(2613)
| | `-{at-spi2-registr}(2614)
| |-dbus-daemon(2579)
| |-dconf-service(2966)-+-{dconf-service}(2967)
| | `-{dconf-service}(2968)
| |-gnome-keyring-d(3038)-+-{gnome-keyring-d}(3040)
| | `-{gnome-keyring-d}(3041)
| |-gvfs-afc-volume(2749)-+-{gvfs-afc-volume}(2750)
| | |-{gvfs-afc-volume}(2751)
| | `-{gvfs-afc-volume}(2753)
| |-gvfs-goa-volume(2741)-+-{gvfs-goa-volume}(2746)
| | `-{gvfs-goa-volume}(2747)
| |-gvfs-gphoto2-vo(2758)-+-{gvfs-gphoto2-vo}(2759)
| | `-{gvfs-gphoto2-vo}(2761)
| |-gvfs-mtp-volume(2754)-+-{gvfs-mtp-volume}(2755)
| | `-{gvfs-mtp-volume}(2757)
| |-gvfs-udisks2-vo(2735)-+-{gvfs-udisks2-vo}(2737)
| | `-{gvfs-udisks2-vo}(2738)
| |-gvfsd(2612)-+-gvfsd-dnssd(4655)-+-{gvfsd-dnssd}(46+
| | | `-{gvfsd-dnssd}(46+
| | |-gvfsd-network(4634)-+-{gvfsd-network+
| | | |-{gvfsd-network+
| | | |-{gvfsd-network+
| | | `-{gvfsd-network+
| | |-gvfsd-trash(2768)-+-{gvfsd-trash}(27+
| | | |-{gvfsd-trash}(27+
| | | `-{gvfsd-trash}(50+
| | |-{gvfsd}(2615)
| | `-{gvfsd}(2616)
| |-gvfsd-fuse(2619)-+-{gvfsd-fuse}(2621)
| | |-{gvfsd-fuse}(2623)
| | |-{gvfsd-fuse}(2624)
| | |-{gvfsd-fuse}(2625)
| | `-{gvfsd-fuse}(2626)
| |-gvfsd-metadata(2823)-+-{gvfsd-metadata}(2828)
| | `-{gvfsd-metadata}(2829)
| |-obexd(2837)
| |-pulseaudio(2704)-+-{pulseaudio}(2794)
| | `-{pulseaudio}(2795)
| |-xfce4-notifyd(2689)-+-{xfce4-notifyd}(2696)
| | `-{xfce4-notifyd}(2698)
| `-xfconfd(2668)
|-systemd-hostnam(5075)
|-systemd-journal(403)
|-systemd-logind(900)
|-systemd-udevd(453)
|-udisksd(885)-+-{udisksd}(908)
| |-{udisksd}(917)
| |-{udisksd}(974)
| `-{udisksd}(1016)
|-upowerd(2711)-+-{upowerd}(2716)
| `-{upowerd}(2717)
|-virt-manager(2959)-+-{virt-manager}(2960)
| |-{virt-manager}(2961)
| |-{virt-manager}(2962)
| |-{virt-manager}(2964)
| |-{virt-manager}(2386)
| |-{virt-manager}(2387)
| `-{virt-manager}(6001)
|-virtlogd(2454)
|-wpa_supplicant(886)
`-xfce4-power-man(2659)-+-{xfce4-power-man}(2665)
`-{xfce4-power-man}(2666)
automatically starting commands
Automatically start commands or scripts.
crontab
If your command does not need a display window then it can be started via systemd or via cron e.g.
crontab -e
@reboot sleep 120 && /etc/tripwire-check.sh @reboot su -c '/root/cloud.sh' -s /bin/bash ralph
If you want to turn emailing logfiles to root include:
MAILTO=""
In the crontab file.
profile.d
If your command requires your shell, in particular your display environment
- create a script
#!/bin/bash
# check the user
if [[ $USER != ralph ]]
then
exit
fi
# check if synology cloud drive is running
if ps aux | egrep '[c]loud-drive-daemon'
then
echo "Synology cloud-drive-daemon is already running"
else
echo "Synology cloud-drive-daemon not running - starting it"
/usr/bin/synology-cloud-station-drive
fi
- include your script within /etc/profile.d and it will be executed every time a user logs in. Make sure the script discriminates the user.
.bashrc
If you are running bash shell you can invoke your script for .bashrc, which will not require you to discriminate based on user
vi ~/.bashrc
# check if synology cloud drive is running
if ps aux | egrep '[c]loud-drive-daemon'
then
echo "Synology cloud-drive-daemon is already running"
else
echo "iSynology cloud-drive-daemon not running - starting it"
/usr/bin/synology-cloud-station-drive
fi
via init.d
This is no longer supported on Debian
- install a script in /etc/init.d
ln -s /home/ralph/cloud.sh cloud.sh
via rc.local (Centos)
Warning, scr
- update rc.local
vi /etc/rc.d/rc.local
- launch your shell from there
sh /home/ralph/scripts/cloud.sh
systemd
- include symlink to your startup script e.g.
ln -s /usr/lib/systemd/system/statd.service /etc/systemd/statsd.service
- typical contents
[Unit] Description=statsd service After=network.target StartLimitIntervalSec=0 ProtectHome=true [Service] Type=simple Restart=always RestartSec=1 User=ralph WorkingDirectory=/data/stats ExecStart=/usr/bin/node /data/stats/server1.js [Install] WantedBy=multi-user.target
upstart
- create a startup script e.g.
vi /etc/init/statsd.conf
- include the directives e.g.
start on syno.network.ready stop on runlevel [06] chdir /volume1/stats exec /usr/local/bin/node /volume1/stats/server1.js
cusomize cron
You can prevent cron.service from sending any email to root by putting this at the first line:
MAILTO=""