================================================== How to do common tasks from the Linux command line ================================================== This document is out of date, see :ref:`Solutions Backend Programs`. The following describes how to use the backend programs installed on ``hill301-2.math.rutgers.edu``. The backend programs are installed in the directory ``/data`` on this computer, and all users in the Unix group ``math-solutions`` have permissions to use this directory. Solutions team members are encouraged to create their own subdirectories under ``/data`` for testing, and use the program ``admin/deploy-backend.sh`` to initialize it (for now, ask Anders). One (and only one) team member should configure ``crontab`` to run the backend programs automatically, see points (A) and (B) below. Other team members can use the :ref:`Commands requiring cronenv.sh` to carry out various tasks and for testing. The examples in this document use the directory ``/data/solutions``, but it could be ``/data/whatever``. (A) Change the server and database used by the crontab programs =============================================================== Edit the file /data/solutions/etc/crontab to change the environment variables LIVEHOST and LIVEDB, then install as new crontab file:: cd /data/solutions/etc vim crontab crontab < crontab (B) Disable or change frequency of crontab programs =================================================== Disable daily backup of database:: cd /data/solutions/etc mv cron.daily/70backup cron.disable Re-enable backup:: cd /data/solutions/etc mv cron.disable/70backup cron.daily Change frequency of CSS download to every hour:: cd /data/solutions/etc mv cron.4hours/50css cron.hourly ============================= Commands requiring cronenv.sh ============================= For the following things to work, first make sure to set the same environment variables as the programs started by cron will see:: source /data/solutions/bin/cronenv.sh For example, this sets the variable ``$SOLHOME`` to ``/data/solutions``. (1) Check the log files ======================= Either look at them in the directory $LOG:: less $LOG/formdata.log Or use the program status.sh (in ``$SOLHOME/bin``) to read a summary:: status.sh | less (2) Run a crontab program immediately on LIVE database ====================================================== Run form download:: cd $SOLHOME/etc/cron.15min ./30formdata One-line version:: $SOLHOME/etc/cron.15min/30formdata Run CSS download:: $SOLHOME/etc/cron.4hours/50css (3) Run a crontab program on test database ========================================== Change these environment variables to reflect your wishes:: export LIVEHOST=math-sql2.sas.rutgers.edu export LIVEDB=mathdb_test1 Then do the same as in (2):: $SOLHOME/etc/cron.15min/30formdata (4) Connect to the database servers =================================== The following command connects to the test MySQL server:: mysql --defaults-file=$SOLSECURE/mathdb.cnf \ --host math-sql2.sas.rutgers.edu You can see the hostname of the server you connected to with this SQL command:: select @@hostname; (5) Restore database backup =========================== Restore the (compressed) backup file mathdb-180910-231311.dump.gz to the database mathdb_test1 on math-sql2.sas.rutgers.edu as follows. First delete all tables in the database:: mysql --defaults-file=$SOLSECURE/mathdb.cnf \ --host math-sql2.sas.rutgers.edu MariaDB [(none)]> drop database mathdb_test1; Query OK, 104 rows affected (0.16 sec) MariaDB [(none)]> create database mathdb_test1; Query OK, 1 row affected (0.00 sec) Then upload the backup database:: cd $SOLHOME/backup zcat mathdb-180910-231311.dump.gz \ | mysql --defaults-file=$SOLSECURE/mathdb.cnf \ --host math-sql2.sas.rutgers.edu \ --database mathdb_test1 Note: backspace "``\``" continues the command on next line in bash.