Skip to content

Instantly share code, notes, and snippets.

@mbeall
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbeall/95e2f7b6ea0db942a5b0 to your computer and use it in GitHub Desktop.
Save mbeall/95e2f7b6ea0db942a5b0 to your computer and use it in GitHub Desktop.
Turk's homework

USER is the user's home directory, i.e. queral

PATH

  • On your team machine, edit the .bashrc file in your home directory.
vi ~/.bashrc
  • At the bottom of the file, type export PATH=$PATH:~/etc
  • Save and quit ( :wq )
  • If it does not already exist create a new directory in your home folder:
mkdir ~/etc
  • From the command line, type:
source ~/.bashrc
echo $PATH
  • If you did everything correctly, /home/USER/etc should appear when you echo $PATH

crontab -e (Part 1)

  • Edit the crontab (crontab -e) so the last two lines look like the following:
# m  h  dom mon dow   command
  *  *  *   *   *     echo "$(whoami): $(date): Hello (Part 1)" >> ~/etc/cron_output.data
  • Save and quit. Wait a minute, then type cat ~/etc/cron_output.data. It should look like the following:
USER: Mon Dec  8 11:53:01 MST 2014: Hello (Part 1)
USER: Mon Dec  8 11:54:01 MST 2014: Hello (Part 1)
  • If you see output like shown above, wait 5 minutes, then move on to next step. If you do not, something is wrong.

crontab -e (Part 2)

  • Create a new script in your ~/etc directory:
vi ~/etc/cron_hello_part2
  • This file should look like the following:
#!/bin/bash
echo "$(whoami): $(date): Hello (Part 2)" >> ~/etc/cron_output.data
  • Edit the crontab file (crontab -e), commenting out the line from the previous step and adding a line for the new script.
# m  h  dom mon dow   command
#  *  *  *   *   *     echo "$(whoami): $(date): Hello (Part 1)" >> ~/etc/cron_output.data
  *  *  *   *   *     ~/etc/cron_hello_part2
  • Wait a minute, then type tail -n5 ~/etc/cron_output.data. It should look like the following:
USER: Mon Dec  8 11:55:01 MST 2014: Hello (Part 1)
USER: Mon Dec  8 11:56:01 MST 2014: Hello (Part 1)
USER: Mon Dec  8 11:57:01 MST 2014: Hello (Part 1)
USER: Mon Dec  8 11:58:01 MST 2014: Hello (Part 2)
USER: Mon Dec  8 11:59:01 MST 2014: Hello (Part 2)
  • If you see output like shown above, wait 5 minutes, then move on to next step. If you do not, something is wrong.

sudo crontab -e (Part 3)

  • Edit the system crontab (sudo crontab -e) so the last two lines look like the following:
# m  h  dom mon dow   command
  *  *  *   *   *     echo "$(whoami): $(date): Hello (Part 3)" >> ~USER/etc/cron_output.data
  • Save and quit. Wait a minute, then type tail -n5 ~USER/etc/cron_output.data. It should look like the following:
USER: Mon Dec  8 11:57:01 MST 2014: Hello (Part 1)
USER: Mon Dec  8 11:58:01 MST 2014: Hello (Part 2)
USER: Mon Dec  8 11:59:01 MST 2014: Hello (Part 2)
USER: Mon Dec  8 12:00:01 MST 2014: Hello (Part 3)
USER: Mon Dec  8 12:01:01 MST 2014: Hello (Part 3)
  • If you see output like shown above, wait 5 minutes, then move on to next step. If you do not, something is wrong.

sudo crontab -e (Part 4)

  • Create a new script in your ~/etc directory:
vi ~USER/etc/cron_hello_part4
  • This file should look like the following:
#!/bin/bash
echo "$(whoami): $(date): Hello (Part 4)" >> ~USER/etc/cron_output.data
  • Edit the system crontab file (sudo crontab -e), commenting out the line from the previous step and adding a line for the new script.
# m  h  dom mon dow   command
#  *  *  *   *   *     echo "$(whoami): $(date): Hello (Part 3)" >> ~USER/etc/cron_output.data
  *  *  *   *   *     ~USER/etc/cron_hello_part4
  • Wait a minute, then type tail -n5 ~USER/etc/cron_output.data. It should look like the following:
USER: Mon Dec  8 11:59:01 MST 2014: Hello (Part 2)
USER: Mon Dec  8 12:00:01 MST 2014: Hello (Part 3)
USER: Mon Dec  8 12:01:01 MST 2014: Hello (Part 3)
USER: Mon Dec  8 12:02:01 MST 2014: Hello (Part 4)
USER: Mon Dec  8 12:03:01 MST 2014: Hello (Part 4)
  • If you see output like shown above, wait 5 minutes, then move on to next step. If you do not, something is wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment