Friday 10 August 2012

At schedule task in linux




#nano test.sh
 Ls > /dev/tty2
Date > /dev/tty2
#chmod +x test.sh
To run this script on 21 Feb 2010 after seven days you need to schedule at command as shown here
#at –f /root/test.sh now +7 days
To run this script after ten minutes you need to schedule at command as shown here
#at –f /root/test.sh now +10 minutes
To run this script now you need to schedule at command as shown here
#at –f /root/test.sh now
To run this script on 10:15 AM you need to schedule at command as shown here
#at –f /root/test.sh 10:15 AM

To check the status of your jobs, so you can see if it will work, run the following job queue command:
#atq
If there's a problem with the job, you can remove it with the atrm command. In this example you would remove job number 4 with the following command:
#atrm 4

·         /etc/at.allow If present then only users those name are in this file can use at daemons
  • /etc/at.deny If present then only user those name are in this file will not be able to use at daemons apart from these user all other can use at daemons
  • If both files are not present then only root can access at daemons
For example create two user Vinita and nikita
These files are formatted as one line per user; add user vinita to at.allow
#nano /etc/at.allow
Vinita
Save and close
To test login on other terminal from user vinita and schedule job from at commands
#at 12:00
Now login on other terminal from nikita and schedule job form at commands
#at

No comments:

Post a Comment