[ Pobierz całość w formacie PDF ]
.0, which you can find with thefollowing:# printenv | fgrep DISPLAYThis command line pipes the output of the printenv command through fgrep to searchyour environment variables (discussed in Hour 6, Using the Shell ) for the value ofyour $DISPLAY environment variable.You can also use the at command to provide a visual reminder, if you re using X11, bycontrolling the color of your desktop, for example:# at 16:15at> xsetroot -display :0.0 -solid Redat> xmessage -display :0.0 The car pool is leaving in 15 minutes.at>warning: commands will be executed using /bin/shjob 14 at 1998-12-18 16:1523 526-2 CH18 8/26/99 10:54 AM Page 401Personal Productivity Tools 401FIGURE 18.1The at command canbe used to run anyOpenLinux program orX11 client, such asxmessage, as areminder.This turns your desktop, or root display, a solid red color at the appointed time and thendisplays your message.As you can see, you can combine multiple commands to do anumber of things simultaneously.If you find this approach convenient, you can also typethese commands into a text file called carpool and run the commands by using the -foption, followed by the name of the file, with the following:# at 16:15 -f carpoolwarning: commands will be executed using /bin/shjob 13 at 1998-12-18 10:19The at command reads the commands from your text file and responds with a confirma-tion.As a further convenience, you can place this command line in your.xintrc scriptin your home directory to schedule the job after you start X11 at the beginning of the18day.See Hour 7, Using the X Window System, for more information about con-figuring your.xinitrc file.Use the atq command to see a list of all your scheduled jobs, like this:# atq14 1998-12-18 12:00 a15 1998-12-18 13:00 a16 1998-12-18 14:00 a17 1998-12-18 15:00 a18 1998-12-25 16:15 aThis shows that four jobs are scheduled for December 18 with another scheduled forDecember 25.When you schedule jobs with the at command, a shell script containingeach command is created in the /var/spool/atjobs directory.The atq command looksin this directory for your jobs and then prints them to your display.23 526-2 CH18 8/26/99 10:54 AM Page 402402 Hour 18You can use the at command to schedule a job minutes, hours, days, weeks, or evenyears in advance.If you want to run your car pool reminder file in three hours, you canuse the at command s plus sign (+) command-line option, for example:# at +3 hours -f carpoolThis runs your job three hours from the current system time.You can also use the timeand date (in the form of mm/dd/yy) to schedule jobs, like so:# at 16:15 12/25/00at> xmessage -display :0.0 The car pool is leaving in 15 minutes.at>warning: commands will be executed using /bin/shjob 21 at 2000-12-31 16:15As you can see, the at command is Y2K-compliant! Use the atrm command to controlyour at jobs.You can selectively delete specific jobs by number.For example, using yourjob queue from the earlier example, you can type the following:# atrm 16 18This removes jobs 16 and 18 but leaves the other two intact.Using the at command is ahandy way to program one-time reminders for specific times.In the next section, I llshow you how to schedule other jobs to run at regular intervals.You can also use Rob Nation s X11 clock client, rclock, to schedulereminders or run programs at a selected day or time.To build a reminder,create a file called.rclock in your home directory, and enter reminder com-mand lines.For example:11:30 mtwtf Time for lunch!This displays a reminder for lunch during the week.The rclock client isusually distributed with the X11 rxvt terminal, but does not come withOpenLinux.You can get the latest version from http://babyaga.math.fu-berlin.de/~rxvt/, or you can also get both rxvt and rclock in an.rpmfile from http://metalab.unc.edu/pub/Linux/X11/terms/.For a diverse list-ing of different clocks (many with alarms) for OpenLinux and X11, browse tohttp://metalab.unc.edu/pub/Linux/X11/clocks.23 526-2 CH18 8/26/99 10:54 AM Page 403Personal Productivity Tools 403Scheduling Regular Reminders with thecrontab CommandAlthough the at command is helpful for scheduling one-time jobs, you can use PaulVixie s crontab command if you need regular tasks completed at regular intervals.Thecrontab command, found under the /usr/bin directory, is used to enter your desiredtimes and commands into a personal file.The crontab command works by looking for crontab schedules by username in the/var/spool/cron directory.The crontab file for your Linux system is called crontaband is located in the /etc directory.The program that runs the system and the user cronschedules is the cron daemon, which is started when you boot Linux and wakes up eachminute to check the system and user files.To create your own crontab file, you must use the command s -e option, for example:# crontab -eMake sure you enable crontab use for your system.See Hour 24,18 Scheduling for details on how to do this
[ Pobierz całość w formacie PDF ]