So, what does a Linux system administrator do? Our most recent work was to schedule a process on an AWS
Linux server (which we set up ) to run every 5 minutes.
Scheduling process in /etc/crontab:
*/5 * * * * root /usr/idletest/1.sh
And this is /usr/idletest/1.sh:
#!/bin/bash -e
/usr/bin/uptime >> /usr/idletest/itsrunning.txt
l='logdata'
ct=$(date "+%Y.%m.%d-%H.%M.%S")
f="$l$ct"
mongoexport -h ds163XX.mlab.com:64XC --collection logsbackup --db idletest -u art -p aaXXXXX --out /usr/idletest/$f
php /usr/idletest/l2.php
You may be more comfortable with Windows batch files; the idea is the same.
This file, 1.sh, is a collection of commands to the operating system.
On the second line we add a time stamp to a file noting the time the command ran. On the next line we place "logdata" into a variable,
and then take the date and time from the system and place it into other variables.
We then run a MongoDB utility, Mongoexport, and use this local MongoDB server process to output a series of remote Mlab Mongo "records" to a
local file. Note the use of the aforementioned Linux shell variables to craft a file name with the embedded name and then date and time.
After this has run we call a PHP program we wrote that uses the data.
|