I'm trying to get a script to run according to a crontab entry. The script I have works fine in the terminal but will not run automatically as per the cron entry. The script is simply to create an empty file in the /testexport1 directory once an hour.
I used crontab -e to edit the crontab, which looks like this:
30 * * * * /bin/bash/ /testexport1/./createfilescript.sh
The script itself looks like this:
[root@centostest testexport1]# cat createfilescript.sh
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/testexport1
today="$( date +"%Y%m%d" )"
number=0
while test -e "$today$suffix.txt"; do
(( ++number ))
suffix="$( printf -- '-%02d' "$number" )"
done
fname="$today$suffix.txt"
printf 'Will use "%s" as filename\n' "$fname"
touch "$fname"
I added the PATH part to the top of the script to specify where the script was being run from (as per another article I have read).
Any ideas why this crontab entry does not seem to be running the script? Simple fix I'm sure but I'm going around in circles at the mo.