Advertisement

Systemd基础:5:timer实现示例代码

阅读量:
在这里插入图片描述

在前文对[service]相关内容的阐述中已指出,并非所有systemd的配置文件均包含该段设置,本文将对在Systemd环境中通过定时器实现相关功能的方式进行说明。

场景介绍

本示例将通过将计时器与特定服务进行绑定,实现每分钟触发一次调用的目标。该服务的运作方式参考了前文所述的相关内容。

服务示例展示

复制代码
    [root@liumiaocn system]# cat liumiaocn.service 
    [Unit]
    Description=Systemd Service Sample By liumiaocn
    Documentation=
    
    [Service]
    WorkingDirectory=/tmp/systemd_working_dir
    ExecStart=/bin/sh -c '/usr/bin/echo "hello world" >>/tmp/systemd_working_dir/hello.log'
    
    [Install]
    WantedBy=m

全部评论 (0)

还没有任何评论哟~