Primal Habits
It is currently Sun Mar 26, 2017 7:08 am


Feed

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Cron At and Batch
PostPosted: Mon Nov 29, 2010 2:20 pm 
Offline
User avatar

Joined: Sun Apr 25, 2010 1:02 pm
Posts: 115



Cron At and Batch
While cron is used to schedule recurring tasks, the at command is used to schedule a one-time task at a specific time and the batch command is used to schedule a one-time task to be executed when the systems load average drops below 0.8.

To use at or batch, the at RPM package must be installed, and the atd service must be running. To determine if the package is installed, use the rpm -q at command. To determine if the service is running, use the command /sbin/service atd status.

Configuring At Jobs
To schedule a one-time job at a specific time, type the command at time, where time is the time to execute the command.

The argument time can be one of the following:

HH:MM format — For example, 04:00 specifies 4:00 a.m. If the time is already past, it is executed at the specified time the next day.

midnight — Specifies 12:00 a.m.

noon — Specifies 12:00 p.m.

teatime — Specifies 4:00 p.m.

month-name day year format — For example, January 15 2002 specifies the 15th day of January in the year 2002. The year is optional.

MMDDYY, MM/DD/YY, or MM.DD.YY formats — For example, 011502 for the 15th day of January in the year 2002.

now + time — time is in minutes, hours, days, or weeks. For example, now + 5 days specifies that the command should be executed at the same time five days from now.

The time must be specified first, followed by the optional date. For more information about the time format, read the /usr/share/doc/at-<version>/timespec text file.

After typing the at command with the time argument, the at> prompt is displayed. Type the command to execute, press Enter, and type Ctrl-D . Multiple commands can be specified by typing each command followed by the Enter key. After typing all the commands, press Enter to go to a blank line and type Ctrl-D . Alternatively, a shell script can be entered at the prompt, pressing Enter after each line in the script, and typing Ctrl-D on a blank line to exit. If a script is entered, the shell used is the shell set in the user's SHELL environment, the user's login shell, or /bin/sh (whichever is found first).

If the set of commands or script tries to display information to standard out, the output is emailed to the user.

Use the command atq to view pending jobs.

Configuring Batch Jobs

To execute a one-time task when the load average is below 0.8, use the batch command.

After typing the batch command, the at> prompt is displayed. Type the command to execute, press Enter, and type Ctrl-D . Multiple commands can be specified by typing each command followed by the Enter key. After typing all the commands, press Enter to go to a blank line and type Ctrl-D . Alternatively, a shell script can be entered at the prompt, pressing Enter after each line in the script, and typing Ctrl-D on a blank line to exit. If a script is entered, the shell used is the shell set in the user's SHELL environment, the user's login shell, or /bin/sh (whichever is found first). As soon as the load average is below 0.8, the set of commands or script is executed.

If the set of commands or script tries to display information to standard out, the output is emailed to the user.

Use the command atq to view pending jobs.

Viewing Pending Jobs
To view pending at and batch jobs, use the atq command. The atq command displays a list of pending jobs, with each job on a line. Each line follows the job number, date, hour, job class, and username format. Users can only view their own jobs. If the root user executes the atq command, all jobs for all users are displayed.

Additional Command Line Options
Additional command line options for at and batch include.

-f Read the commands or shell script from a file instead of specifying them at the prompt.
-m Send email to the user when the job has been completed.
-v Display the time that the job is executed.

Controlling Access to At and Batch
The /etc/at.allow and /etc/at.deny files can be used to restrict access to the at and batch commands. The format of both access control files is one username on each line. Whitespace is not permitted in either file. The at daemon (atd) does not have to be restarted if the access control files are modified. The access control files are read each time a user tries to execute the at or batch commands.

The root user can always execute at and batch commands, regardless of the access control files.

If the file at.allow exists, only users listed in it are allowed to use at or batch, and the at.deny file is ignored.

If at.allow does not exist, users listed in at.deny are not allowed to use at or batch.

Starting and Stopping the Service
To start the at service, use the command /sbin/service atd start. To stop the service, use the command /sbin/service atd stop. It is recommended that you start the service at boot time.

_________________
Check Out RouterHead8080 T.V.



Share on FacebookShare on TwitterShare on TuentiShare on SonicoShare on FriendFeedShare on OrkutShare on DiggShare on MySpaceShare on DeliciousShare on Technorati
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours [ DST ]


Related topics
 Topics   Author   Replies   Views   Last post 
There are no new unread posts for this topic. cron MAN page

RouterHead8080

0

2776

Mon Nov 29, 2010 2:11 pm

RouterHead8080 View the latest post

There are no new unread posts for this topic. How to cancel cron job

RouterHead8080

0

1247

Tue Nov 22, 2011 11:51 am

RouterHead8080 View the latest post

There are no new unread posts for this topic. Setting cron job for clamav

RouterHead8080

0

1320

Tue Nov 22, 2011 11:28 am

RouterHead8080 View the latest post

 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron

Affiliates    Terms of use    Privacy policy   

Primal Habits, a Sceptersoft Company
Copyright © 2010 - 2017 Sceptersoft LLC. All rights reserved.