Pacific-Design.com

    
Home Index

1. Bash

2. Crontab

Bash / Crontab /

#---------------------------------------------------------#
19 19 * * mon-fri ./cron-manager.sh
23 23 * * mon-fri ./cron-manager.sh start
#---------------------------------------------------------#
10 10 * * sat,sun ./cron-manager.sh
23 23 * * sat,sun ./cron-manager.sh start
#---------------------------------------------------------#

#!/bin/bash                                                                                                         
#---------------------------------------------------------------------#
IP="192.168.0.14 192.168.0.15 192.168.0.5"
#---------------------------------------------------------------------#
stop_service() {

    for node in $IP 
    do  
        echo "ssh root@$node /bin/systemctl start crond.service"
        ssh root@$node /bin/systemctl start crond.service 
    
        echo "ssh root@$node killall -u spider"
        ssh root@$node killall -u spider
    
    done

}
#---------------------------------------------------------------------#
start_service() {

    for node in $IP 
    do  
        echo "ssh root@$node /bin/systemctl start crond.service" 
        ssh root@$node /bin/systemctl start crond.service 
    
    done

}
#---------------------------------------------------------------------#

if [ "$1" = "start" ]; then
    echo "Starting Cron Service"
    start_service
else
    echo "Stopping Cron Service"
    stop_service
fi