{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs2042_Lecture8

cs2042_Lecture8 - CS2042 Unix Tools Fall 2009 Lecture 8...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2042 - Unix Tools Fall 2009 Lecture 8 David Slater dms236 at cornell.edu October 16, 2009 David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Organization Homework 1 Due Next Wednesday! David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 2
Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile Prints the length of the longest line gawk ’END { print NR } ’ infile David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 4
Some Review What does this do? gawk ’BEGIN { max = 0 } { if (length($0) > max); max = length($0) } END { print max } ’ infile Prints the length of the longest line gawk ’END { print NR } ’ infile Prints how many lines are in the file David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Backup Last time we wrote a simple script to backup a directory: backupwithdate.sh #! /bin/bash tar -czf /backups/cs2042_$(date +%%d_%m_%y).tar.gz \ /Documents/cs2042/ What if we wanted to run this script automatically, say nightly? David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 6
cron cron cron is a program that enables unix users to execute commands or scripts automatically at a specified date/time cron is a daemon, which means it only needs to be started once and will lay dormant until it is required On most Linux distributions is automatically installed and entered into the start up scripts: Check by tying ps -e | grep cron Depending on your system, it may show up as cron or crond We can control the cron daemon in a few different ways... David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cron and root If you have a look in your /etc directory you will find sub directories called cron.hourly cron.daily cron.weekly cron.monthly If you place a script in any of these directories, it will be run either hourly, daily, weekly or monthly depending on the name of the directory. Note: If we did this with our backup script, we would need to replace with /home/slater since the script would be run as root . David Slater dms236 at cornell.edu CS2042 - Unix Tools
Image of page 8
cron flexibility If you want more flexibility in scheduling you can edit a crontab file crontab crontab files are cron’s config files.
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern