Re: Is there a way to modify cron entries via a Shell Script?

From: Jim Richardson (magilla_48138_at_yahoo.com)
Date: 02/26/04


Date: 26 Feb 2004 08:22:49 -0800

v_borchert@despammed.com (Volker Borchert) wrote in message news:<c1jo7o$4k7$1@Gaia.teknon.de>...
> rkbeach wrote:
>
> |> Can anyone please let me know if there's a way (or am I asking
> |> something that's impossible) in which one can modify cron entries via a
> |> Shell Script? Any pointers/code will be very helpful...
> |>
> |> I have to modify cron entries on 30 machines...am trying to see
> |> if I can somehow automate this process...
>
> RTFM:
>
> User Commands crontab(1)
>
> NAME
> crontab - user crontab file
>
> SYNOPSIS
> crontab [ filename ]
>
> crontab [ -elr ] username
>
> DESCRIPTION
> The crontab utility manages a user's access with cron by
> copying, creating, listing, and removing crontab files. If
> invoked without options, crontab copies the specified file,
> or the standard input if no file is specified, into a direc-
> tory that holds all users' crontabs.
>
> crontab -l, pipe through sed to temporary file, crontab < file.

The below snippet is from a csh script that performs the initial
configuration of our Solaris servers. It basically creates 5 entries
into the user's crontab file via the "/usr/bin/ed" editor. Via the
editor you can create, delete, and modify any entry. The text between
the "${CAT}" line and the second "END-CRONTAB" is obviously contained
within the csh script; therefore, variable substitution can be used.

Jim Richardson

  setenv EDITOR ${ED}

  ${CAT} << END-CRONTAB | ${CRONTAB} -e >& ${NULL}
\$a
# daily
#
 0 4 * * * /usr/local/lib/newlogdaily.pl >/dev/null 2>&1
55 23 * * * /group/sysad/cs/bin/syschk.solaris
# weekly
#
 5 4 * * 6 /usr/local/lib/newlogweekly.pl >/dev/null 2>&1
27 20 * * 6 /group/sysad/cs/bin/hware.chk
# monthly
#
10 4 1 * * /usr/local/lib/newlogmonthly.pl >/dev/null 2>&1
.
w
q
END-CRONTAB



Relevant Pages

  • Strange cron behavoir
    ... A user has a crontab file setup to run various nightly jobs. ... This was enabled in cron many months ago, ...
    (SunManagers)
  • crontab root not found
    ... was being interpreted as a normal user crontab file and it was trying to run ... This email communication is intended as a private communication for the sole ... Cette communication par courrier électronique est une communication privée à ...
    (freebsd-questions)
  • RE: Question on Crontab; unable to edit/list
    ... The -u param is for use by the root user to access other user's ... crontab files. ... their own crontab file and "crontab -e -u xxx" for root to edit ... > what else can cause this err msg to come? ...
    (RedHat)
  • Re: running a crontab from command line, ad hoc
    ... If it's another user crontab that you want to run, ... root previledge. ... edit the crontab file and copy paste it to a terminal ...
    (RedHat)
  • Re: Is there a way to modify cron entries via a Shell Script?
    ... rkbeach wrote: ... |> I have to modify cron entries on 30 machines...am trying to see ... The crontab utility manages a user's access with cron by ...
    (comp.unix.solaris)