USER
is the user's home directory, i.e. queral
- 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 youecho $PATH
- 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.
- 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.
- 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.
- 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.