Running a cron every 30 seconds

后端 未结 19 1000
面向向阳花
面向向阳花 2020-11-22 10:56

Ok so I have a cron that I need to run every 30 seconds.

Here is what I have:

*/30 * * * * /bin/bash -l -c \'cd /srv/last_song/releases/2012030813315         


        
19条回答
  •  逝去的感伤
    2020-11-22 11:48

    You can run that script as a service, restart every 30 seconds

    Register a service

    sudo vim /etc/systemd/system/YOUR_SERVICE_NAME.service
    

    Paste in the command below

    Description=GIVE_YOUR_SERVICE_A_DESCRIPTION
    
    Wants=network.target
    After=syslog.target network-online.target
    
    [Service]
    Type=simple
    ExecStart=YOUR_COMMAND_HERE
    Restart=always
    RestartSec=10
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    

    Reload services

    sudo systemctl daemon-reload
    

    Enable the service

    sudo systemctl enable YOUR_SERVICE_NAME
    

    Start the service

    sudo systemctl start YOUR_SERVICE_NAME
    

    Check the status of your service

    systemctl status YOUR_SERVICE_NAME
    

提交回复
热议问题