Project

General

Profile

RandomCrontab ยป droneCreateRandomCron.sh

Dominik Meyer, 12/23/2024 08:02 PM

 
#!/bin/bash

OCCURANCE=$1
REPO=$2
BRANCH=$3
CNAME=$4


if [ -z $CNAME ]; then
echo "Usage: droneCreateRandomCron.sh <occurance> <repository> <branch> <crontab name>"
echo -e "\t occurance = 1 = Daily | 0 = Weekly"
exit 1
fi



HOUR=$(($RANDOM % 24))

if [ $1 -eq 1 ]; then

DAY='*'

else

DAY=$(($RANDOM % 6))

fi

CRONTAB="0 0 ${HOUR} * * ${DAY}"
echo "Crontab: ${CRONTAB}"

drone cron add --branch $BRANCH $REPO $CNAME "${CRONTAB}"


    (1-1/1)