====== AIX create you own demon (daemon) ======
Create fksubsys service:
mkssys -p /path/to/fkcmd \ # Absolute path to subsystem bin or script
-a "arg1 arg2" \ # if Arguments to the command
-s fksubsys \ # Unique name for the subsystem (-t fkalias)
-G fkgrp \ # Subsys group
-u 202 \ # User id for the subsystem (0 for root)
-i /dev/console \ # Stdin got from (default)
-o /dev/console \ # Stdout sent to (default)
-e /dev/console \ # Stderr sent to (default)
-R \ # Restart subsys if halted abnormally (or -O)
-Q \ # One instance only # -q if multiple instances
-S \ # Subsys supports signals
\ # or -I msgqueue -m msgtype (or -K if sockets)
-f 9 \ # signal KILL for forced stopsrc -f
-n 15 \ # signal TERM for normal stopsrc
-w 10 \ # 10 seconds between a TERM and KILL & restart)
-E 24 \ # Subsys priority (20 default)
-d # lssrc -a lists subsys even if inactive else -D
lssrc -S -s fksubsys # Check the service's configuration: OR...
odmget -q subsysname=fksubsys SRCsubsys # ... via the odm.
startsrc -s fksubsys # startsrc -g fkgrp # two ways to launch it
stopsrc -s fksubsys # and to stop it
mkitab -i cron fkcmd:2:respawn:startsrc -s fksubsys # start subsys via /etc/inittab
Change the subsystem:
chssys -s old_subsystem_name
{[-s new_subsystem_name]
[-t synonym_name]
[-a command_arguments]
[-p subsystem_path]
[-u userid]
[-i stdin]
[-o stdout]
[-e stderr]
[-R | -O]
[-d | -D]
[-q | -Q]
[{-I message_queue_key -m subsystem_mtype}
| {-S -n signorm -f sigforce} | -K]
[-E priority]
[-G group_name]
[-w wait_time] }
==== Debug a demon ====
# startsrc -s lpd -a "-D /tmp/lpd.debug"
Example of demon, for printer demon
[root@nim]/root# odmget -q subsysname=lpd SRCsubsys
SRCsubsys:
subsysname = "lpd"
synonym = ""
cmdargs = ""
path = "/usr/sbin/lpd"
uid = 0
auditid = 0
standin = "/dev/console"
standout = "/dev/console"
standerr = "/dev/console"
action = 1
multi = 0
contact = 3
svrkey = 0
svrmtype = 0
priority = 20
signorm = 0
sigforce = 0
display = 1
waittime = 20
grpname = "spooler"
Redirect errors and standard output to /dev/null
[root@nim]/root# chssys -s lpd -e "/dev/null" -o "/dev/null"
0513-077 Subsystem has been changed.
[root@nim]/root# odmget -q subsysname=lpd SRCsubsys
SRCsubsys:
subsysname = "lpd"
synonym = ""
cmdargs = ""
path = "/usr/sbin/lpd"
uid = 0
auditid = 0
standin = "/dev/console"
standout = "/dev/null"
standerr = "/dev/null"
action = 1
multi = 0
contact = 3
svrkey = 0
svrmtype = 0
priority = 20
signorm = 0
sigforce = 0
display = 1
waittime = 20
grpname = "spooler"
Then restart the demon (you can sometimes use refresh -s lpd)
[root@nim]/root# stopsrc -s lpd ; startsrc -s lpd
To remove a subsystem, use
# rmssys -s Subsystem