so I have been seeing something really weird and perhaps simple? but not simple enough that I have not been able to figure out. I have written a simple bash script that I am able to run without issues normally, the issue comes when I schedule a cron job which then does not run my script.
The script is executable, the script can be executed manually without errors/issues. I tried adding it to the crontab with the following:
# crontab -l
30 * * * * /usr/scripts/test_script.sh
I have also tried to add a file under /etc/cron.d/test_script
and tried to specify the path and shell:
# cat /etc/cron.d/tes_script
PATH=/bin:/usr/bin:/sbin:/usr/sbin
SHELL=/bin/bash
30 * * * * /usr/scripts/test_script.sh
I have been trying to check the logs with tailf /var/log/syslog
and I see the following:
Feb 7 10:53:01 CRON[29203]: (root) CMD (/usr/scripts/test_script.sh)
so it seems like it might be runnign but in reality is not, (it triggers an update process that can be seen on a web interface for the program).
is there anything that I might be missing? Here is the script
#!/bin/bash
DIST="ubuntu"
LOGS="/var/logs/test_script.log"
RECIPIENTS="[email protected]"
declare -a POCKET=("release" "security" "updates")
xenial()
{
SERIES="xenial"
for pocket in "${POCKET[@]}"
do
bzip2 -d "$HOLDER"*.bz2
sync-pocks "$pocket" "$SERIES" "$DIST"
sleep 5m
done
return 0
}
precise()
{
SERIES="precise"
for pocket in "${POCKET[@]}"
do
bzip2 -d "$HOLDER"*.bz2
sync-pocks "$pocket" "$SERIES" "$DIST"
sleep 5m
done
return 0
}
xenial &> "$LOGS" &&
precise &>> "$LOGS" ||
cat "$LOGS" | mailx -s "Sync" "$RECIPIENTS"
Could it possibly some syntax issue on the script? and if so, why would it run without issues when ran manually?
HOLDER
get a value?