Im trying to create a dynamic cronjob which executes a PHP script which needs a DB argument for specific directorys.
The Output should look like this:
/usr/bin/php /var/www/html/test.php db_test
I got following:
#!/bin/bash
DIR="/var/www/html/*"
PHP="/usr/bin/php"
ACCOUNTS=$(ls -d $DIR)
DBPREFIX="db_"
DB=$( find /var/www/html/ -mindepth 1 -maxdepth 1 -type d | awk -F'/' '{print $5}' )
for CUSTOMER in $ACCOUNTS
do
echo $PHP $CUSTOMER $DBPREFIX$DB
done
This outputs following:
/usr/bin/php /var/www/html/test.php db_test test2 test3 test4
The Problem is that the DBPREFIX and DB vars need also to go trough a loop so that i get for every single db a complete command.
How am I able to do so?