Hire me if you like: blake.irvin@gmail.com

Thursday, February 26, 2009

Scheduling a One-time Job with 'at'

This is a bit of old-school Unix. We tell the 'at' command to execute a job at 8pm in this case - 20:00 hours:

root@host:~# at 2000
at> [command] [arguments]

(Above, we press 'return' after entering our command string, then ctrl-D to exit)

root@host:/var/spool/cron/atjobs# less 1235696400.a
: at job
: jobname: stdin
: notify by mail: no
: project: 1
export MANPATH; MANPATH='/usr/gnu/share/man:/usr/share/man:/usr/X11/share/man'
export HZ; HZ=''
export SHELL; SHELL='/usr/bin/bash'
export TERM; TERM='vt100'
export PAGER; PAGER='/usr/bin/less -ins'
export MAIL; MAIL='/var/mail/root'
export PATH; PATH='/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin'
export PWD; PWD='/root'
export LANG; LANG='en_US.UTF-8'
export TZ; TZ='US/Eastern'
export SHLVL; SHLVL='1'
export HOME; HOME='/root'
export LOGNAME; LOGNAME='root'
export _; _='/usr/bin/at'
$SHELL << '...the rest of this file is shell input'
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
cd /root
umask 22
[command] [arguments]

No comments: