summaryrefslogtreecommitdiff
path: root/setcrontab
blob: c811307659f935de8a827b93f026a2be678d0cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

#
# setcrontab
# Copyright (C) 1996,2012  Free Software Foundation, Inc.
# $Id: setcrontab,v 1.2 2002/01/03 04:35:18 johnh Exp $
#

usage () {
	cat <<END
usage: $0 newcrontabfile

Sets the users crontab to whatever's given in stdin.
Works around the dumb (only interactive) crontab -e interface.
END
	#' 
}

TMP=/tmp
FE=$TMP/$$.fakeeditor
NCT=$1

trap 'rm -f $FE $NCT; exit 1' 1 2 15

# stdin to the crontab

cat >$FE <<END
#!/bin/sh
cat $NCT >\$1
exit 0
END

chmod 0700 $FE
EDITOR=$FE
VISUAL=$FE
export EDITOR VISUAL

crontab -e

rm -f $FE $NCT
exit 0