Sunday, January 30, 2011

at jobs in SuSE Linux

In SuSE you log on as root and start YaST. When the YaST window appears click on the system icon on the left side of the window. The right side of the window will get new icons. Look for the icon labeled "Runlevel Editor". Click on that and it will start a new window. Find atd in the list. Highlight atd and click on the "Enable" button. You should see a message indicating whether it worked or not. If it worked then you can use the at command right away. It will also start the atd process whenever you restart the system.

Thanks to https://calomel.org/cron_at.html
At "how to"

To use "at" you need to know the structure and how to complete the command.

at 5am Oct 20 at "time am/pm" "month" "day"
atq lists the user's pending jobs
atrm deletes jobs, identified by their job number
Ctrl-d once done editing use Ctrl-d to close the "at" entry shell
To run jobs only once it is easier to use "at" than to setup and cron job and then go back and remove it once the job has ran. Remember you need to have the "atd" daemon running on Linux systems to run "at" jobs. On OpenBSD or FreeBSD system the "crond" daemon will handle "cron" and "at" jobs.

To run an "at" job you need to fist tell "at" what time to run the job. Remember to use absolute paths to avoid confusion. Once to execute att with the time and date you will be put into an "at" shell. This is where you will enter the commands you want to execute, one command per line to make it simple.

In this example we will be executing a set of commands at 5am on January 23rd. The backup script will run and then we will send out mail to root. To close the "at" shell and save the job you must type Ctrl-d (the control key with the lowercase d).

user@machine:~$ at 5am Jan 23
at> /tools/run_backups.sh
at> echo "job done" | mail -s "backup job finished" root
at> Ctrl-d
job 1 at 2008-01-23 05:00
Once you have completed entering your commands and type Ctrl-d "at" will respond with the job number and a verification printout of when the job is going to run. If you made a mistake and ran the job at the wrong time you can usr "atrm" to remove the job and re-enter your job with the current time.