1. at
2. cron tab
“at” is used to schedule the job for a particular time or interval, in other words, it is used only for one time or only for one interval.
Syn: at [options]
Examples:
1. $ at 9am At> date Ctrl+d (save & quit)
2. $at now +3 days At> /bin/echo “hello world” Ctrl+d (save & quit)
3. $ at 03222013 At> ls Ctrl +d (save & quit)
4. $at 1:30 3/22/2013 At> cp file1 file2 Ctrl+d (Save & quit)
5. $at –f filename 11pm At> /bin/echo “hello world” Ctrl+d (save & quit)
Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training
$ at - l (or) $ atq
$ at – d 1 (or) $ atrm 1
$at q
To View the job details:
$ at -c 2
The atd service uses two files to control access to the services
/etc/at.allow /etc/at.deny The /etc/at.allow file:
If it exists, only these users are allowed (at.deny is ignored).
If it doesn’t exist, all users except at deny are permitted.
The /etc/at.deny file:
If it exists and is empty, all users are allowed (red hat default)
If neither file exists, root only.
The default setting for a red hat allows any user to create a cron job. As the root user, you also have the ability to edit and remove any cron job you want. Let’s jump into creating a cron job for the system. You can use the crontab command to create, edit, and delete jobs.
Syn: Crontab [-u use] [option]
Options:
Before you start using the crontab command, however, you should look over the format it uses so you understand how to create and edit cron jobs. Each user has her own crontab file in /var/spool/cron, based on the username of each user. Any “allow” actions taken by the cron service are logged to /var/log/cron.
Examples:
# Crontab –e
*/01 * * * * date
*/30 11 * * * cp file1 file2
45 10,22 03 * * /bin/echo “Hello world”
50 22 01,11 10 * logname
59 23 31 12 * /bin/echo “Happy New Year” */01 * * * 0,6 /bin/echo “Today is weekend” : wq !
To check assigned cronjobs:
# crontab –l
# service crond status
#Service crond restart #Chkconfig crond on
#corntab –u user01 -e * * * * * /tmp/sample_script :wq!
#crontab -U user01 -r
# tail /var/log/cron *
Note: What do you think happens if you set up cron jobs to run during the night (say, to run some reports) and you shut down the system right before you go home? Well, it runs out that there is another great feature of cron. The /etc/anacrontab file defines fobs that should be run every time the system is started. If your system is turned off during the time that a cron job should have run, when the system boots again, the cron service will call/etc/anacrontab to make sure that all missed cron jobs are run.
# cat / etc/anacrontab
/etc/cron.allow. /etc/cron.deny.
If it exists, only these users are allowed (cron.deny is ignored)
If it doesn’t exist, all users except cron. Deny is permitted.
If it exists and is empty, all users are allowed (red hat default)
If neither file exists, root only.
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/4
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox