shell case

#!/bin/sh

DRINK="beer"
case "$DRINK" in
	"beer") echo "this is beer"
	;;
	"juice") echo "that is juice"
	;;
	"coak") echo "Do not drink it"
	;;
esac

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
this is beer

esacとか、使い慣れてないなー

shell if

#!/bin/sh

if [ "$1" -gt "$2" ]
then
	echo "1番目の引数が2番目の引数より大きい"
elif [ "$1" -eq "$2" ]
then
	echo "1番目の引数と2番目の引数は同じです"
else
	echo "1番目の引数が2番目の引数より小さい"
fi

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh 5 4
1番目の引数が2番目の引数より大きい

shell special variable

Variable Function
$0 script name
Access $1 ~ $9 arguments, $1 for the first argument, $2 for the second argument

$ # number of arguments given to the script
$ * treat all arguments together as one
$ @ Thread all arguments as separate
$? End value of the last executed command (0 is success, 1 is failure)
$$ Process ID of this shell script
$! last executed background process ID

#!/bin/sh

echo "\$0 (スクリプト名): $0"
echo "\$1 (1番目の引数): $1"
echo "\$2 (2番目の引数): $2"
echo "\$# (引数の数): $#"
echo "\"\$*\": \"$*\""
echo "\"\$@\": \"$@\""
VAR="exit値は0になるはずです"
echo $?

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
$0 (スクリプト名): ./test.sh
$1 (1番目の引数): 
$2 (2番目の引数): 
$# (引数の数): 0
“$*”: “”
“$@”: “”
0

shell variables

Can use single-byte alphanumeric characers and underscores as variable name. a to z, A to Z, 0 to 9 and _.
When giving a value to a variable, write = without leading and trailing blanks. If it is a string, enclose it in “.
Put $ before the variable name when accessing the variable. or put $ and enclose the variable in {}.
Only one value can be stored in one variable.
Use readonly to not overwrite the value of the variable. Variables can be deleted by unset. (You can not delete the readonly variable.)

#!/bin/sh

var="yukijirushi"
var2="coffee"
echo "I'm drinking $var2"

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
I’m drinking coffee

なるほど。

#!/bin/sh

var="yukijirushi"
var2="coffee"
echo "I'm drinking $var2"

var2="traditional test"
echo ${var2}

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
I’m drinking coffee
traditional test

ここまでは簡単

sed -i ‘s/\r//’

Shell script is simply to execute Unix command etc. side by side. It is responsible for when to execute what instruction and what condition, read file contents, and write log file.

#!/bin/sh

echo "Hello, World!"

[vagrant@localhost tests]$ chmod 755 test.sh
[vagrant@localhost tests]$ ./test.sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
sed: -e 表現 #1, 文字数 1: 未知のコマンドです: 「▒」
[vagrant@localhost tests]$ ./test.sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
Hello, World!

#!/bin/sh


# コメントです。
read NAME
echo "Hello, $NAME!"

あれ、コマンドラインが止まる? なんでだろう。。

rtc_cmos

Hardware clock
– Time on hardware(BIOS). It is maintained even in the power off state
Realtime clock
– Same as hardware clock
System clock
– Time on OS(software clock)

[vagrant@localhost ~]$ sudo hwclock
2019年03月01日 03時10分29秒  -1.030445 秒
[vagrant@localhost ~]$ sudo hwclock --utc
2019年03月01日 12時10分43秒  -0.835191 秒
[vagrant@localhost ~]$ sudo hwclock --localtime
2019年03月01日 03時11分04秒  -0.189680 秒
[vagrant@localhost ~]$ date
2019年  3月  2日 土曜日 16:49:41 JST
[vagrant@localhost ~]$ date -u
2019年  3月  2日 土曜日 07:49:53 UTC

[vagrant@localhost ~]$ timedatectl
-bash: timedatectl: コマンドが見つかりません

[vagrant@localhost ~]$ dmesg
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-754.3.5.el6.x86_64 (mockbuild@x86-01.bsys.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) ) #1 SMP Tue Aug 14 20:46:41 UTC 2018
Command line: ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=ja_JP.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
KERNEL supported cpus:
Intel GenuineIntel
AMD AuthenticAMD
Centaur CentaurHauls
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 – 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 000000001fff0000 (usable)
BIOS-e820: 000000001fff0000 – 0000000020000000 (ACPI data)
BIOS-e820: 00000000fec00000 – 00000000fec01000 (reserved)
BIOS-e820: 00000000fee00000 – 00000000fee01000 (reserved)
BIOS-e820: 00000000fffc0000 – 0000000100000000 (reserved)
SMBIOS version 2.5 @ 0xFFF60
SMBIOS 2.5 present.
DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Hypervisor detected: KVM
e820 update range: 0000000000000000 – 0000000000001000 (usable) ==> (reserved)
e820 remove range: 00000000000a0000 – 0000000000100000 (usable)
last_pfn = 0x1fff0 max_arch_pfn = 0x400000000
x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
CPU MTRRs all blank – virtualized system.
initial memory mapped : 0 – 20000000
init_memory_mapping: 0000000000000000-000000001fff0000
0000000000 – 001fe00000 page 2M
001fe00000 – 001fff0000 page 4k
kernel direct mapping tables up to 1fff0000 @ 8000-b000
RAMDISK: 1ec11000 – 1ffdf2d0
ACPI: Deleted _OSI(Windows 2012)
ACPI: Deleted _OSI(Windows 2013)
ACPI: RSDP 00000000000e0000 00024 (v02 VBOX )
ACPI: XSDT 000000001fff0030 0003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061)
ACPI: FACP 000000001fff00f0 000F4 (v04 VBOX VBOXFACP 00000001 ASL 00000061)
ACPI: DSDT 000000001fff0470 021C8 (v02 VBOX VBOXBIOS 00000002 INTL 20100528)
ACPI: FACS 000000001fff0200 00040
ACPI: APIC 000000001fff0240 00054 (v02 VBOX VBOXAPIC 00000001 ASL 00000061)
ACPI: SSDT 000000001fff02a0 001CC (v01 VBOX VBOXCPUT 00000002 INTL 20100528)
ACPI: Local APIC address 0xfee00000
Setting APIC routing to flat.
No NUMA configuration found
Faking a node at 0000000000000000-000000001fff0000
Bootmem setup node 0 0000000000000000-000000001fff0000
NODE_DATA [0000000000009000 – 000000000003cfff]
bootmap [000000000003d000 – 0000000000040fff] pages 4
(7 early reservations) ==> bootmem [0000000000 – 001fff0000]
#0 [0000000000 – 0000001000] BIOS data page ==> [0000000000 – 0000001000]
#1 [0000006000 – 0000008000] TRAMPOLINE ==> [0000006000 – 0000008000]
#2 [0001000000 – 0002052a64] TEXT DATA BSS ==> [0001000000 – 0002052a64]
#3 [001ec11000 – 001ffdf2d0] RAMDISK ==> [001ec11000 – 001ffdf2d0]
#4 [000009f800 – 0000100000] BIOS reserved ==> [000009f800 – 0000100000]
#5 [0002053000 – 000205313c] BRK ==> [0002053000 – 000205313c]
#6 [0000008000 – 0000009000] PGTABLE ==> [0000008000 – 0000009000]
found SMP MP-table at [ffff88000009fff0] 9fff0
crashkernel=auto resulted in zero bytes of reserved memory.
kvm-clock: Using msrs 4b564d01 and 4b564d00
kvm-clock: cpu 0, msr 0:1c3db81, boot clock
[ffffea0000000000-ffffea00007fffff] PMD -> [ffff880002600000-ffff880002dfffff] on node 0
Zone PFN ranges:
DMA 0x00000001 -> 0x00001000
DMA32 0x00001000 -> 0x00100000
Normal 0x00100000 -> 0x00100000
Movable zone start PFN for each node
early_node_map[2] active PFN ranges
0: 0x00000001 -> 0x0000009f
0: 0x00000100 -> 0x0001fff0
On node 0 totalpages: 130958
DMA zone: 56 pages used for memmap
DMA zone: 100 pages reserved
DMA zone: 3842 pages, LIFO batch:0
DMA32 zone: 1736 pages used for memmap
DMA32 zone: 125224 pages, LIFO batch:31
ACPI: PM-Timer IO Port: 0x4008
ACPI: Local APIC address 0xfee00000
Setting APIC routing to flat.
ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
ACPI: IOAPIC (id[0x01] address[0xfec00000] gsi_base[0])
IOAPIC[0]: apic_id 1, version 32, address 0xfec00000, GSI 0-23
ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
ACPI: IRQ0 used by override.
ACPI: IRQ2 used by override.
ACPI: IRQ9 used by override.
Using ACPI (MADT) for SMP configuration information
SMP: Allowing 1 CPUs, 0 hotplug CPUs
nr_irqs_gsi: 24
PM: Registered nosave memory: 000000000009f000 – 00000000000a0000
PM: Registered nosave memory: 00000000000a0000 – 00000000000f0000
PM: Registered nosave memory: 00000000000f0000 – 0000000000100000
Allocating PCI resources starting at 20000000 (gap: 20000000:dec00000)
Booting paravirtualized kernel on KVM
NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1
PERCPU: Embedded 33 pages/cpu @ffff880002200000 s104088 r8192 d22888 u2097152
pcpu-alloc: s104088 r8192 d22888 u2097152 alloc=1*2097152
pcpu-alloc: [0] 0
kvm-clock: cpu 0, msr 0:2218b81, primary cpu clock
Built 1 zonelists in Node order, mobility grouping on. Total pages: 129066
Policy zone: DMA32
Kernel command line: ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=ja_JP.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
PID hash table entries: 2048 (order: 2, 16384 bytes)
x86/fpu: xstate_offset[2]: 0240, xstate_sizes[2]: 0100
xsave: enabled lazy FPU xstate_bv 0x7, cntxt size 0x440
Memory: 478016k/524224k available (5540k kernel code, 392k absent, 45816k reserved, 6889k data, 1348k init)
Kernel/User page tables isolation: enabled
Hierarchical RCU implementation.
NR_IRQS:33024 nr_irqs:256
Console: colour VGA+ 80×25
console [tty0] enabled
allocated 2097152 bytes of page_cgroup
please try ‘cgroup_disable=memory’ option if you don’t want memory cgroups
Detected 2400.000 MHz processor.
Calibrating delay loop (skipped) preset value.. 4800.00 BogoMIPS (lpj=2400000)
pid_max: default: 32768 minimum: 301
Security Framework initialized
SELinux: Initializing.
SELinux: Starting in permissive mode
Dentry cache hash table entries: 65536 (order: 7, 524288 bytes)
Inode-cache hash table entries: 32768 (order: 6, 262144 bytes)
Mount-cache hash table entries: 256
Initializing cgroup subsys ns
Initializing cgroup subsys cpuacct
Initializing cgroup subsys memory
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys net_cls
Initializing cgroup subsys blkio
Initializing cgroup subsys perf_event
Initializing cgroup subsys net_prio
mce: CPU supports 0 MCE banks
using mwait in idle threads.
Speculative Store Bypass: Vulnerable
FEATURE SPEC_CTRL Not Present
FEATURE IBPB_SUPPORT Not Present
Spectre V2 : Vulnerable: Retpoline on Skylake+
alternatives: switching to unfair spinlock
SMP alternatives: switching to UP code
Freeing SMP alternatives: 38k freed
ACPI: Core revision 20090903
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 22079 entries in 87 pages
Enabling x2apic
Enabled x2apic
APIC routing finalized to physical x2apic.
..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
CPU0: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz stepping 03
Performance Events: unsupported p6 CPU model 78 no PMU driver, software events only.
NMI watchdog disabled (cpu0): hardware events not enabled
Brought up 1 CPUs
Total of 1 processors activated (4800.00 BogoMIPS).
sizeof(vma)=200 bytes
sizeof(page)=56 bytes
sizeof(inode)=592 bytes
sizeof(dentry)=192 bytes
sizeof(ext3inode)=800 bytes
sizeof(buffer_head)=104 bytes
sizeof(skbuff)=232 bytes
sizeof(task_struct)=2672 bytes
devtmpfs: initialized
regulator: core version 0.5
NET: Registered protocol family 16
ACPI: bus type pci registered
PCI: Using configuration type 1 for base access
bio: create slab at 0
ACPI: EC: Look up EC in DSDT
ACPI: Executed 1 blocks of module-level executable AML code
ACPI: Interpreter enabled
ACPI: (supports S0 S5)
ACPI: Using IOAPIC for interrupt routing
ACPI: No dock devices found.
PCI: Ignoring host bridge windows from ACPI; if necessary, use “pci=use_crs” and report a bug
ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] (ignored)
pci_root PNP0A03:00: host bridge window [io 0x0d00-0xffff] (ignored)
pci_root PNP0A03:00: host bridge window [mem 0x000a0000-0x000bffff] (ignored)
pci_root PNP0A03:00: host bridge window [mem 0x20000000-0xffdfffff] (ignored)
PCI: root bus 00: using default resources
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
pci_bus 0000:00: root bus resource [mem 0x00000000-0x7fffffffff]
pci 0000:00:01.1: reg 20: [io 0xd000-0xd00f]
pci 0000:00:02.0: reg 10: [mem 0xe0000000-0xe07fffff pref]
pci 0000:00:03.0: reg 10: [mem 0xf0000000-0xf001ffff]
pci 0000:00:03.0: reg 18: [io 0xd010-0xd017]
pci 0000:00:04.0: reg 10: [io 0xd020-0xd03f]
pci 0000:00:04.0: reg 14: [mem 0xf0400000-0xf07fffff]
pci 0000:00:04.0: reg 18: [mem 0xf0800000-0xf0803fff pref]
pci 0000:00:05.0: reg 10: [io 0xd100-0xd1ff]
pci 0000:00:05.0: reg 14: [io 0xd200-0xd23f]
pci 0000:00:07.0: quirk: [io 0x4000-0x403f] claimed by PIIX4 ACPI
pci 0000:00:07.0: quirk: [io 0x4100-0x410f] claimed by PIIX4 SMB
pci 0000:00:08.0: reg 10: [mem 0xf0820000-0xf083ffff]
pci 0000:00:08.0: reg 18: [io 0xd240-0xd247]
pci 0000:00:0d.0: reg 10: [io 0xd248-0xd24f]
pci 0000:00:0d.0: reg 18: [io 0xd258-0xd25f]
pci 0000:00:0d.0: reg 20: [io 0xd270-0xd27f]
pci 0000:00:0d.0: reg 24: [mem 0xf0840000-0xf0841fff]
ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]
ACPI: PCI Interrupt Link [LNKA] (IRQs 5 9 10 *11)
ACPI: PCI Interrupt Link [LNKB] (IRQs 5 9 10 *11)
ACPI: PCI Interrupt Link [LNKC] (IRQs 5 9 *10 11)
ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *9 10 11)
vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none
vgaarb: loaded
vgaarb: bridge control possible 0000:00:02.0
SCSI subsystem initialized
libata version 3.00 loaded.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
PCI: Using ACPI for IRQ routing
PCI: old code would have set cacheline size to 32 bytes, but clflush_size = 64
PCI: pci_cache_line_size set to 64 bytes
NetLabel: Initializing
NetLabel: domain hash size = 128
NetLabel: protocols = UNLABELED CIPSOv4
NetLabel: unlabeled traffic allowed by default
Switching to clocksource kvm-clock
pnp: PnP ACPI init
ACPI: bus type pnp registered
pnp 00:00: [io 0x0cf8-0x0cff]
pnp 00:00: Plug and Play ACPI device, IDs PNP0a03 (active)
pnp 00:01: [io 0x0060]
pnp 00:01: [io 0x0064]
pnp 00:01: [irq 1]
pnp 00:01: Plug and Play ACPI device, IDs PNP0303 (active)
pnp 00:02: [io 0x0000-0x000f]
pnp 00:02: [io 0x0080-0x008f]
pnp 00:02: [io 0x00c0-0x00df]
pnp 00:02: [dma 4]
pnp 00:02: Plug and Play ACPI device, IDs PNP0200 (active)
pnp 00:03: [irq 12]
pnp 00:03: Plug and Play ACPI device, IDs PNP0f03 (active)
pnp: PnP ACPI: found 4 devices
ACPI: ACPI bus type pnp unregistered
pci_bus 0000:00: resource 4 [io 0x0000-0xffff]
pci_bus 0000:00: resource 5 [mem 0x00000000-0x7fffffffff]
NET: Registered protocol family 2
IP route cache hash table entries: 4096 (order: 3, 32768 bytes)
TCP established hash table entries: 16384 (order: 6, 262144 bytes)
TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
TCP reno registered
NET: Registered protocol family 1
pci 0000:00:00.0: Limiting direct PCI/PCI transfers
Unknown Intel PCH (0x7000) detected
Warning: Intel Skylake processor with unknown PCH – this hardware has not undergone testing by Red Hat and might not be certified. Please consult https://hardware.redhat.com for certified hardware.
pci 0000:00:01.0: Activating ISA DMA hang workarounds
pci 0000:00:02.0: Boot video device
Trying to unpack rootfs image as initramfs…
Freeing initrd memory: 20280k freed
platform rtc_cmos: registered platform RTC device (no PNP device found)
sha256_ssse3: Using AVX optimized SHA-256 implementation
futex hash table entries: 256 (order: 2, 16384 bytes)
audit: initializing netlink socket (disabled)
type=2000 audit(1551367125.626:1): initialized
HugeTLB registered 2 MB page size, pre-allocated 0 pages
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
msgmni has been set to 973
SELinux: Registering netfilter hooks
ksign: Installing public key data
Loading keyring
– Added public key FB76F4358054719F
– User ID: CentOS (Kernel Module GPG key)
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
pci_hotplug: PCI Hot Plug PCI Core version: 0.5
pciehp: PCI Express Hot Plug Controller Driver version: 0.4
acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
ACPI: AC Adapter [AC] (on-line)
input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
ACPI: Power Button [PWRF]
input: Sleep Button as /devices/LNXSYSTM:00/LNXSLPBN:00/input/input1
ACPI: Sleep Button [SLPF]
ACPI: acpi_idle registered with cpuidle
[Firmware Bug]: No valid trip found
GHES: HEST is not enabled!
Non-volatile memory driver v1.3
Linux agpgart interface v0.103
crash memory driver: version 1.1
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
brd: module loaded
loop: module loaded
input: Macintosh mouse button emulation as /devices/virtual/input/input2
Fixed MDIO Bus: probed
ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
uhci_hcd: USB Universal Host Controller Interface driver
PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12
serio: i8042 KBD port at 0x60,0x64 irq 1
serio: i8042 AUX port at 0x60,0x64 irq 12
ACPI: Battery Slot [BAT0] (battery present)
mice: PS/2 mouse device common for all mice
input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input3
rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0
rtc0: alarms up to one day, 114 bytes nvram
cpuidle: using governor ladder
cpuidle: using governor menu
EFI Variables Facility v0.08 2004-May-17
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input4
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
GRE over IPv4 demultiplexor driver
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
registered taskstats version 1
rtc_cmos rtc_cmos: setting system clock to 2019-02-28 15:18:36 UTC (1551367116)
Initalizing network drop monitor service
Freeing unused kernel memory: 1348k freed
Write protecting the kernel read-only data: 10240k
Freeing unused kernel memory: 584k freed
Freeing unused kernel memory: 1524k freed
dracut: dracut-004-411.el6
device-mapper: uevent: version 1.0.3
device-mapper: ioctl: 4.33.1-ioctl (2015-8-18) initialised: dm-devel@redhat.com
udev: starting version 147
ACPI: Video Device [GFX0] (multi-head: yes rom: no post: no)
input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/LNXVIDEO:00/input/input5
dracut: Starting plymouth daemon
dracut: rd_NO_MD: removing MD RAID activation
ata_piix 0000:00:01.1: version 2.13
ata_piix 0000:00:01.1: setting latency timer to 64
scsi0 : ata_piix
scsi1 : ata_piix
ata1: PATA max UDMA/33 cmd 0x1f0 ctl 0x3f6 bmdma 0xd000 irq 14
ata2: PATA max UDMA/33 cmd 0x170 ctl 0x376 bmdma 0xd008 irq 15
ahci 0000:00:0d.0: version 3.0
alloc irq_desc for 21 on node -1
alloc kstat_irqs on node -1
ahci 0000:00:0d.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
ahci: SSS flag set, parallel bus scan disabled
ahci 0000:00:0d.0: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
ahci 0000:00:0d.0: flags: 64bit ncq stag only ccc
ahci 0000:00:0d.0: setting latency timer to 64
scsi2 : ahci
ata3: SATA max UDMA/133 abar m8192@0xf0840000 port 0xf0840100 irq 21
Refined TSC clocksource calibration: 2400.600 MHz.
ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata3.00: ATA-6: VBOX HARDDISK, 1.0, max UDMA/133
ata3.00: 83886080 sectors, multi 128: LBA48 NCQ (depth 31/32)
ata3.00: configured for UDMA/133
scsi 2:0:0:0: Direct-Access ATA VBOX HARDDISK 1.0 PQ: 0 ANSI: 5
sd 2:0:0:0: [sda] 83886080 512-byte logical blocks: (42.9 GB/40.0 GiB)
sd 2:0:0:0: [sda] Write Protect is off
sd 2:0:0:0: [sda] Mode Sense: 00 3a 00 00
sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn’t support DPO or FUA
sda: sda1 sda2
sd 2:0:0:0: [sda] Attached SCSI disk
dracut: Scanning devices sda2 for LVM logical volumes VolGroup/lv_swap VolGroup/lv_root
dracut: inactive ‘/dev/VolGroup/lv_root’ [38.54 GiB] inherit
dracut: inactive ‘/dev/VolGroup/lv_swap’ [992.00 MiB] inherit
EXT4-fs (dm-0): INFO: recovery required on readonly filesystem
EXT4-fs (dm-0): write access will be enabled during recovery
EXT4-fs (dm-0): orphan cleanup on readonly fs
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1324994
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1315228
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1315028
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1315018
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1315017
EXT4-fs (dm-0): ext4_orphan_cleanup: deleting unreferenced inode 1314903
EXT4-fs (dm-0): 6 orphan inodes deleted
EXT4-fs (dm-0): recovery complete
EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts:
dracut: Mounted root filesystem /dev/mapper/VolGroup-lv_root
SELinux: Disabled at runtime.
SELinux: Unregistering netfilter hooks
type=1404 audit(1551367124.248:2): selinux=0 auid=4294967295 ses=4294967295
dracut:
dracut: Switching root
udev: starting version 147
e1000: Intel(R) PRO/1000 Network Driver – version 7.3.21-k8-NAPI
e1000: Copyright (c) 1999-2006 Intel Corporation.
alloc irq_desc for 19 on node -1
alloc kstat_irqs on node -1
e1000 0000:00:03.0: PCI INT A -> GSI 19 (level, low) -> IRQ 19
e1000 0000:00:03.0: setting latency timer to 64
e1000 0000:00:03.0: eth0: (PCI:33MHz:32-bit) 08:00:27:a9:1b:8f
e1000 0000:00:03.0: eth0: Intel(R) PRO/1000 Network Connection
alloc irq_desc for 16 on node -1
alloc kstat_irqs on node -1
e1000 0000:00:08.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
e1000 0000:00:08.0: setting latency timer to 64
e1000 0000:00:08.0: eth1: (PCI:33MHz:32-bit) 08:00:27:cb:a5:1b
e1000 0000:00:08.0: eth1: Intel(R) PRO/1000 Network Connection
alloc irq_desc for 20 on node -1
alloc kstat_irqs on node -1
vboxguest 0000:00:04.0: PCI INT A -> GSI 20 (level, low) -> IRQ 20
vgdrvHeartbeatInit: Setting up heartbeat to trigger every 2000 milliseconds
input: Unspecified device as /devices/pci0000:00/0000:00:04.0/input/input6
vboxguest: misc device minor 57, IRQ 20, I/O port d020, MMIO at 00000000f0400000 (size 0x400000)
vboxguest: Successfully loaded version 5.1.26 (interface 0x00010004)
Intel ICH 0000:00:05.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
Intel ICH 0000:00:05.0: setting latency timer to 64
intel8x0_measure_ac97_clock: measured 645910 usecs (13373 samples)
intel8x0: measured clock 20704 rejected
intel8x0_measure_ac97_clock: measured 51579 usecs (11076 samples)
intel8x0: measured clock 214738 rejected
intel8x0_measure_ac97_clock: measured 51001 usecs (11520 samples)
intel8x0: measured clock 225877 rejected
intel8x0: clocking to 48000
piix4_smbus 0000:00:07.0: SMBus Host Controller at 0x4100, revision 0
sd 2:0:0:0: Attached scsi generic sg0 type 0
EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:
Adding 1015804k swap on /dev/mapper/VolGroup-lv_swap. Priority:-1 extents:1 across:1015804k
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
ADDRCONF(NETDEV_UP): eth0: link is not ready
e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
ADDRCONF(NETDEV_UP): eth1: link is not ready
e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
eth0: no IPv6 routers present
vboxsf: Successfully loaded version 5.1.26 (interface 0x00010004)
type=1305 audit(1551334767.682:3): audit_pid=1148 old=0 auid=4294967295 ses=4294967295 res=1
eth1: no IPv6 routers present
VBoxService 5.1.26 r117224 (verbosity: 0) linux.amd64 (Jul 27 2017 13:45:26) release log
00:00:00.000206 main Log opened 2019-02-28T06:19:31.732032000Z
00:00:00.000465 main OS Product: Linux
00:00:00.000546 main OS Release: 2.6.32-754.3.5.el6.x86_64
00:00:00.000631 main OS Version: #1 SMP Tue Aug 14 20:46:41 UTC 2018
00:00:00.000727 main Executable: /opt/VBoxGuestAdditions-5.1.26/sbin/VBoxService
00:00:00.000731 main Process ID: 1312
00:00:00.000735 main Package type: LINUX_64BITS_GENERIC
00:00:00.002429 main 5.1.26 r117224 started. Verbose level = 0
00:00:00.023496 vminfo Error: Unable to connect to system D-Bus (1/3): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
00:00:05.029812 vminfo Error: Unable to connect to system D-Bus (2/3): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
00:00:10.034472 vminfo Error: Unable to connect to system D-Bus (3/3): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
ADDRCONF(NETDEV_UP): eth1: link is not ready
e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
なんじゃこりゃー

rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0
rtc_cmosの記載はあったが、何を意味してるんだこれ??

cat /etc/rc.d/init.d/halt

#!/bin/bash
#
# halt          This file is executed by init when it goes into runlevel
#               0 (halt) or runlevel 6 (reboot). It kills all processes,
#               unmounts file systems and then either halts or reboots.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Damien Neil
#

NOLOCALE=1
. /etc/init.d/functions

UMOUNT="umount"
[ ! -w /etc ] && UMOUNT="umount -n"

halt_crypto() {
    fnval=0
    while read dst src key; do
        [ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue
        if [ -b "/dev/mapper/$dst" ]; then
            if /sbin/dmsetup info "$dst" | grep -q '^Open count: *0$'; then
                action $"Stopping disk encryption for $dst" /sbin/cryptsetup remove "$dst"
            else
                fnval=1
            fi
        fi
    done < /etc/crypttab
    return $fnval
}

kill_all() {
    local STRING rc

    STRING=$1
    echo -n "$STRING "
    shift
    /sbin/killall5 "$@"
    rc=$?
    # Retval: 0: success 1: error 2: no processes found to kill
    if &#91; "$rc" == 1 &#93;; then
        failure $"$STRING"
    else
        success $"$STRING"
    fi
    echo
    return $rc
}

# See how we were called.
case "$0" in
   *halt)
        message=$"Halting system..."
        command="/sbin/halt"
        ;;
   *reboot)
        message=$"Please stand by while rebooting the system..."
        command="/sbin/reboot"
        kexec_command="/sbin/kexec"
        ;;
   *)
        echo $"$0: call me as 'halt' or 'reboot' please!"
        exit 1
        ;;
esac
case "$1" in
   *start)
        ;;
   *)
        echo $"Usage: $0 {start}"
        exit 1
        ;;
esac

# Kill all processes.
&#91; "${BASH+bash}" = bash &#93; && enable kill

# Find mdmon pid's and omit killing them
OMITARGS=
for i in /dev/md/*.pid; do
    if &#91; ! -r "$i" &#93;; then
        continue
    fi
    OMITARGS="$OMITARGS -o $(cat $i)"
done

kill_all $"Sending all processes the TERM signal..." -15 $OMITARGS
# No need to sleep and kill -9 if no processes to kill were found
if &#91; "$?" == 0 &#93;; then
    sleep 2
    kill_all $"Sending all processes the KILL signal..." -9 $OMITARGS
fi

# Write to wtmp file before unmounting /var
/sbin/halt -w

# Save mixer settings, here for lack of a better place.
if &#91; -s /etc/alsa/alsactl.conf -a -x /sbin/alsactl -a -w /etc/asound.state &#93;; then
  action $"Saving mixer settings" /sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --ignore store
fi

# Save random seed
touch /var/lib/random-seed
chmod 600 /var/lib/random-seed
action $"Saving random seed: " dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null

[ -x /sbin/hwclock -a -e /dev/rtc ] && action $"Syncing hardware clock to system time" /sbin/hwclock --systohc

# Try to unmount tmpfs filesystems to avoid swapping them in.  Ignore failures.
tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; }
             $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r)
[ -n "$tmpfs" ] && fstab-decode $UMOUNT $tmpfs 2>/dev/null

# Turn off swap, then unmount file systems.
[ -f /proc/swaps ] && SWAPS=$(awk '! /^Filename/ { print $1 }' /proc/swaps)
if [ -n "$SWAPS" ]; then
    action $"Turning off swap: " swapoff $SWAPS
    for dst in $SWAPS; do
        if [[ "$dst" == /dev/mapper* ]] \
            && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then
            backdev=$(/sbin/cryptsetup status "$dst" \
                | awk '$1 == "device:" { print $2 }')
            /sbin/cryptsetup remove "$dst"
        fi
    done
fi

[ -x /sbin/quotaoff ] && action $"Turning off quotas: " /sbin/quotaoff -aug

# Unmount file systems, killing processes if we have to.
# Unmount loopback stuff first
__umount_loopback_loop

# Unmount RPC pipe file systems
__umount_loop '$3 ~ /^rpc_pipefs$/ || $3 ~ /^rpc_svc_gss_pipefs$/ {print $2}' \
    /proc/mounts \
    $"Unmounting pipe file systems: " \
    $"Unmounting pipe file systems (retry): " \
    -f

LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
        $3 == "tmpfs" || $3 == "proc" {print $2 ; next}
        $3 ~ /(loopfs|autofs|nfs|cifs|smbfs|ncpfs|sysfs)/ {next}
        /(^none|^\/dev\/ram|^\/dev\/root$)/ {next}
        {print $2}' /proc/mounts \
        $"Unmounting file systems: " \
        $"Unmounting file systems (retry): " \
        -f

[ -f /proc/bus/usb/devices ] && $UMOUNT /proc/bus/usb

[ -f /etc/crypttab ] && halt_crypto

# remove the crash indicator flag
rm -f /.autofsck

# Try all file systems other than root, essential filesystems and RAM disks,
# one last time.
awk '$2 !~ /\/(|dev|proc|selinux|sys)$/ && $1 !~ /^\/dev\/ram/ { print $2 }' \
    /proc/mounts | sort -r | \
  while read line; do
    fstab-decode $UMOUNT -f $line
done

HALTARGS="-d"
[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"

if [ -x /sbin/halt.local ]; then
   /sbin/halt.local "$message" "$command" "$HALTARGS" "$kexec_command"
fi

# Tell init to re-exec itself.
kill -TERM 1
# And give init some time to do that (#1259873)
sleep 1

# Remount read only anything that's left mounted.
# echo $"Remounting remaining filesystems readonly"
mount | awk '{ print $1,$3 }' | while read dev dir; do
    fstab-decode mount -n -o ro,remount $dev $dir
done

# If we left mdmon's running wait for the raidsets to become clean
if [ -n "$OMITARGS" ]; then
    sync
    HALTARGS="$HALTARGS -n"
    mdadm --wait-clean --scan
fi

# Now halt or reboot.
echo $"$message"
if [ -f /fastboot ]; then
 echo $"On the next boot fsck will be skipped."
elif [ -f /forcefsck ]; then
 echo $"On the next boot fsck will be forced."
fi

# Shutdown UPS drivers
if [ "$command" = /sbin/halt -a -f /etc/sysconfig/ups ]; then
        . /etc/sysconfig/ups
        if [ -z $POWERDOWNFLAG ]; then
                POWERDOWNFLAG=/etc/killpower
        fi
        if [ "$SERVER" = "yes" -a -f $POWERDOWNFLAG ]; then
                /sbin/upsdrvctl shutdown
                sleep 120
                /sbin/reboot --force
        fi
fi

# Turn off UPS in powerfail situation
if [ -x /etc/apcupsd/apccontrol -a -f /etc/apcupsd/powerfail ]; then
        /etc/apcupsd/apccontrol killpower
fi

# First, try kexec. If that fails, fall back to rebooting the old way.
[ -n "$kexec_command" ] && $kexec_command -e -x >& /dev/null


exec $command $HALTARGS

ぎゃーーーーーーーーーーshellだ。。

sh

A shell is a program that interprets and executes commands. Work on linux system is done on the termimnal.
A program(shell) that interprets and executes commands to be entered for each terminal when loggin in to the linux system. It starts to work. There are several kind of shells, and users can select a shell to execute according to their preference.

/dev/null 2>&1

#/bin/bash

echo "this is standard output"

[vagrant@localhost app]$ ./echo.sh
-bash: ./echo.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost app]$ sed -i ‘s/\r//’ echo.sh
[vagrant@localhost app]$ ./echo.sh
this is standard output

It took an hour to come here.

If it is executed normally, it will be displayed on the standard output, but if you redirect it, it will be able to output to another location.

When redirecting to standard error output
[vagrant@localhost app]$ ./echo.sh >&2
this is standard output

When redirecting to standard output
[vagrant@localhost app]$ ./echo.sh >&1
this is standard output

[vagrant@localhost app]$ ./echo.sh > /dev/null
/dev/null is a unix special file, it is an empty file.

Merging standard error output to standard output
2>&1

somehow I got it.

バッチ処理(英語ではBatch proccessing)とは

今更感がありますが。。
バッチ処理:英語ではBatch proccessing

– 一つの流れのプログラムを順次実行すること。
– 予め定められた処理を一度に行う。

PC起動時の処理などもバッチ処理という。
というこは、クローンタブで時間を定めて処理することだけをバッチ処理とは言わない、もっと広義な意味を含めているようですな。

ざっくりというと、まとめて処理ですが、場面によって微妙に違いますね。