Run command every second in Bash?

后端 未结 3 2045
闹比i
闹比i 2020-12-14 05:37

I want to write some image downloader and assign it on bash. What I have and what I need:

I have:

  1. Command, which works fine (something like wget
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 05:58

    To add my two cents to this... If the cron's one minute interval is too long for you, you can take advantage of the systemd's capability to restart services repeatedly.

    [Unit]
    Description=Poll something each second
    
    [Service]
    Type=simple
    ExecStart=/opt/poller/poll.sh
    Restart=always
    RestartSec=1
    StartLimitInterval=0
    
    [Install]
    WantedBy=multi-user.target
    

    I know it's a messy and sort of "never ever do this" approach. But it works perfectly an is fairly simple to set up.

提交回复
热议问题