0

What is the best way to monitor a directory on webserver and automatically create following directories if something happens.

e.g

A dir_1 gets created in monitored_dir. Auto creation of dir_1-1, dir_1-2, ... in dir_1.

ent3
  • 192
  • 1
  • 7

1 Answers1

0

Don't know exactly what you want to do, but think like this?

#!/bin/bash

NUMBER=0
DIR=/srv/monitored_dir/dir_1/

if [[ ! -d "${DIR}" ]]; then
  while [[ $NUMBER -lt 4 ]]; do
    mkdir "${DIR}"-dir_1-"${NUMBER}"
    NUMBER=$["${NUMBER}"+1]
  done
fi
donnie
  • 23
  • 1
  • 7