Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views2 pages

Crontab

Summary

Uploaded by

daudmarley6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Crontab

Summary

Uploaded by

daudmarley6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

JORDAN UNIVERSITY COLLEGE

DEPARTMENT OF INFORMATION SCIENCES


BCS207 – SYSTEM ADMINISTRATION
TASK SCHEDULING
WORKING WITH CRONTAB
1. Change to a director /home/hamisi where hamisi is username
cd /home/hamisi
2. View existing content of crontab
sudo crontab -l
3. Edit content of crontab
sudo crontab -e
4. Add the following entry to be first blank line and save changes
* * * * * date >> /tmp/mydates.txt
5. View (after a minute) if the file mydates has been created using a
command
ls -alS /tmp
6. View the content of the file mydates.txt using a command
cat /tmp/mydates.txt
7. Delete the file mydates.txt using a command
rm /tmp/mydates.txt
8. Create a bash file using a command
sudo nano bash.sh
9. Add the following entries in the editor
#!/bin/bash
date >> /tmp/mydates.txt
10. Exit the editor to the terminal by pressing Ctrl+X, then press Y and then
press Enter key.
11. Open crontab (step 3 above) and add the following entry to the first blank
line and save changes
* * * * * /home/hamisi/bash.sh
12. View (after a minute) if the file mydates.txt has been created using a
command
ls -alS /tmp
13. View the content of the file mydates.txt using a command
cat /tmp/mydates.txt
14. Create a folder test under /home/hamisi/ using a command

Prepare by Churi A.J. [email protected] May 2022


mkdir test
15. create file under the folder test with name myletter.txt using a command
sudo touch /home/hamisi/test/myleter.txt
16. Edit the content of myletter.txt using a command
sudo nano /test/myletter.txt
17. Add the following content into the file myletter.txt
To My Uncle,
How are you doing. This is to let you know that, I am doing well
with my studies. Last semester I got a semester gpa of 4.6 out of
five. I am planning to do well in this semester and get more than
this. Thank you for your continued support
Regards
Hamisi
18. Exit the editor to the terminal by pressing Ctrl+X, then press Y and then
press Enter key.
19. Edit your bash.sh file by writing the following entries (do not delete the
existing contents)
tar -czf /tmp/mybackup.tar.gz /home/hamisi/test
20. View (after a minute) if the file mybackup.tar.gz has been created using a
command
ls -alS /tmp
21. Edit your bash.sh file by writing the following entries (do not delete the
existing contents)
tar -zcf /tmp/mybackup_$(date +%Y-%m-%d_%H%M%S).tar.gz
/home/churi/test
22. Exit the editor to the terminal by pressing Ctrl+X, then press Y and then
press Enter key.
23. View (after a minute) if the file mybackup<date_time>.tar.gz has been
created using a command
ls -alS /tmp
24. View (after a minute) if another file mybackup<date_time>.tar.gz has
been created using a command
ls -alS /tmp
Ensure you understand what does the commands do used in this guide

Prepare by Churi A.J. [email protected] May 2022

You might also like