I have a small "stop script" named "/home/gjd/jobs/cctv0.sh" that creates a halt trigger file to stop processing of a loop in another job. The small "stop script" looks like this:
Code: Select all
#!/bin/bash
#
. /home/gjd/jobs/coredecs.sh # include common variables from master declarations file
. /home/gjd/jobs/cctvdecs.sh # include common variables from camera declarations file
# ***********************************************************************
# * Warning: creation of a shutdown file will stop ALL instances. *
# ***********************************************************************
touch $STOPTRIGGERFILE
exit $?
This script contains an include file thus:
Code: Select all
. /home/gjd/jobs/cctvdecs.sh
and the cctvdecs.sh looks like this:
Code: Select all
#!/bin/bash
#
# Declare the the base name for references to cameras and also for directory naming.
# This isolates such references so that this value can be changed easily in the event of future renaming.
export CCTVBASE=cctv
# Define variable representing the source directory for zipped archive files
export ARCHIVEPATH=/home/gjd/${CCTVBASE}
# Define variable representing the directory for final generated movie files
export MOVIEPATH=/home/gjd/Videos
# Define variable representing the filename that will act as the trigger file to stop other jobs
export STOPTRIGGERFILE=$ARCHIVEPATH/${CCTVBASE}0.txt
# Define the time of day group identities using an array for convenience
export GROUPARRAY=(g0dark g1dawn g2morn1 g3morn2 g4noon g5noonplus g6pm1 g7pm2 g8pm3 g9sleep)
...etc...
The odd behaviour with the small "stop script" is that if I execute it directly at the command line it creates the trigger file. Likewise if I schedule it using cron. In both cases no errors are reported.
However, when I use an ad-hoc execution thus:
Code: Select all
at -f/home/gjd/jobs/cctv0.sh now + 1 min
After some debugging I have managed to determine that the include file variables are defined successfully up to and including the line:
Code: Select all
export STOPTRIGGERFILE etc.
Code: Select all
export GROUPARRAY etc.
No errors are reported anywhere including in '/var/log/syslog'.
No "Stopped jobs" are reported on exit.
So the question remains, why does the above work okay under direct execution and using cron, but not using 'at'?
Can somebody more knowledgeable please enlighten me?
Thanks guys.
---
Linux Mint 18.3 Cinnamon 64-bit
Cinnamon Version: 3.6.7
Linux Kernel: 4.10.0-38-generic