[Cialug] Fwd: Run Once via crontab
kristau
kristau at gmail.com
Wed Jul 20 19:29:12 CDT 2016
Shamelessly ripped off from http://goo.gl/iJfQXa
Directories:
mkdir -p /etc/local/runonce.d/run
chmod -R 700 /etc/local/runonce.d
Crontab entry (root):
# Run any scripts present under /etc/local/runonce.d after rebooting:
@reboot /usr/local/bin/runonce
Script /usr/local/bin/runonce:
#!/bin/sh
# runonce: Run these scripts once at reboot (see crontab), then move them
so they don't run again.
cd /etc/local/runonce.d
for file in *
do
if [ ! -f "$file" ]
then
continue
fi
"/etc/local/runonce.d/$file"
# mv "$file" "/etc/local/runonce.d/ran/$file.$(date +%Y%m%dT%H%M%S)"
mv "$file" "./ran/$file.$(date +%Y%m%dT%H%M%S)"
logger -t runonce -p local3.info "$file"
done
--
Tired programmer
Coding late into the night
The core dump follows
More information about the Cialug
mailing list