centos7 使用systemd 自定义关机前脚本
systemd (centos7)
需求,关机前执行脚本
关机脚本
vi /usr/bin/shutdown_cust.sh
#!/bin/bash
echo "zhengchangguanji" >> /tmp/log.log
chmod +x /usr/bin/shutdown_cust.sh
设置关机执行
[root@localhost ~]# vi /usr/lib/systemd/system/cust_power.service
[Unit]
Description=poweroff cust
After=getty@tty1.service display-manager.service plymouth-start.service
Before=systemd-poweroff.service
DefaultDependencies=no
[Service]
ExecStart=/usr/bin/shutdown_cust.sh
Type=forking
[Install]
WantedBy=poweroff.target
[root@localhost ~]# vi /usr/lib/systemd/system/cust_reboot.service
[Unit]
Description=reboot cust
After=getty@tty1.service display-manager.service plymouth-start.service
Before=systemd-reboot.service
DefaultDependencies=no
[Service]
ExecStart=/usr/bin/shutdown_cust.sh
Type=forking
[Install]
WantedBy=reboot.target
[root@localhost ~]# vi /usr/lib/systemd/system/cust_halt.service
[Unit]
Description=halt cust
After=getty@tty1.service display-manager.service plymouth-start.service
Before=systemd-halt.service
DefaultDependencies=no
[Service]
ExecStart=/usr/sbin/shutdown_cust.sh
Type=forking
[Install]
WantedBy=halt.target
软连接
ln -s /usr/lib/systemd/system/cust_halt.service /usr/lib/systemd/system/halt.target.wants/
ln -s /usr/lib/systemd/system/cust_power.service /usr/lib/systemd/system/power.target.wants/
ln -s /usr/lib/systemd/system/cust_reboot.service /usr/lib/systemd/system/reboot.target.wants/
重启 查看tmp下面会不会多出来log.log 文件
centos7 使用systemd 自定义关机前脚本的更多相关文章
- centos7上systemd详解
centos7上systemd详解 发表于 2016-06-07 | 分类于 linux CentOS 7继承了RHEL 7的新的特性,例如强大的systemd, 而systemd的使用也使得以往 ...
- centos7的systemd
系统启动流程 POST --> Boot Sequence --> Bootloader --> kernel+initramfs(initrd) --> rootfs --& ...
- centos7的systemd命令对比
centos7的systemd命令对比 http://www.linuxidc.com/Linux/2014-09/106490p2.htmhttp://www.linuxidc.com/Linux/ ...
- [转贴]systemd 编写服务管理脚本
[转贴]sparkdev大神的博客, 关于 systemd的配置文件的 介绍, 自己之前二进制安装 k8s 时 超过一个 service文件 但是当时不明不白的. 现在再学习一下大神的文章 的确牛B ...
- Android自定义View前传-View的三大流程-Measure
Android自定义View前传-View的三大流程-Measure 参考 <Android开发艺术探索> https://developer.android.google.cn/refe ...
- android 自定义view 前的基础知识
本篇文章是自己自学自定义view前的准备,具体参考资料来自 Android LayoutInflater原理分析,带你一步步深入了解View(一) Android视图绘制流程完全解析,带你一步步深入了 ...
- 自定义nagios监控脚本---磁盘检测
自定义nagios监控脚本---磁盘检测 1. 在客户端上创建脚本/usr/local/nagios/libexec/check_disk.shvim /usr/local/nagios/libexe ...
- Centos7 自定义systemctl服务脚本
序言篇: 之前工作环境一直使用Centos6版本,脚本一直在使用/etc/init.d/xxx:系统升级到Cento7后,虽然之前的启动脚本也可以使用,但一直没有使用systemctl 的自定义脚本. ...
- Linux学习笔记之Centos7 自定义systemctl服务脚本
0x00 概述 之前工作环境一直使用Centos6版本,脚本一直在使用/etc/init.d/xxx:系统升级到Cento7后,虽然之前的启动脚本也可以使用,但一直没有使用systemctl 的自定义 ...
随机推荐
- 自动换行 lable换行 div换行 span换行 label换行
label word-break: break-all; white-space: normal;
- QT error: cannot find -lGL
自己电脑新搭建的QT5.4.2编程环境,编译的第一个程序出现错误:error: cannot find -lGL 经查证,是找不到GL库,解决办法: sudo apt-get install libg ...
- Unity Standard Assets 简介之 Cameras
这篇介绍Cameras资源包. 文件夹下有名为“CameraGuidelines.txt”的说明文档,简要介绍了各个预设的作用和用法. Prefabs文件夹: CctvCamera.prefab: 视 ...
- Spatial Transformer Networks(空间变换神经网络)
Reference:Spatial Transformer Networks [Google.DeepMind]Reference:[Theano源码,基于Lasagne] 闲扯:大数据不如小数据 这 ...
- 谓词 (NSPredicate)使用详情
谓词 更加详细:http://blog.csdn.net/ztp800201/article/details/8116081 //判断是否满足条件 第一种 判断一个数组(array)中满足条件的 NS ...
- 洛谷 P1026 统计单词个数 Label:dp
题目描述 给出一个长度不超过200的由小写英文字母组成的字母串(约定;该字串以每行20个字母的方式输入,且保证每行一定为20个).要求将此字母串分成k份(1<k<=40),且每份中包含的单 ...
- [Note] Software Testing
Mocking: Difference between error and failure: TDD: BDD:
- embed标签
Embed(一).基本语法:embed src=url说明:embed可以用来插入各种多媒体,格式可以是 Midi.Wav.AIFF.AU.MP3等等, Netscape及新版的IE 都支持 ...
- python 之 前端初识 html
html语法代码示例 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- Docking Windows Phone controls to the bottom of a StackPanel
<Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinit ...