-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS99cronbuild.bak
More file actions
33 lines (32 loc) · 913 Bytes
/
S99cronbuild.bak
File metadata and controls
33 lines (32 loc) · 913 Bytes
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
#!/bin/ksh
export HOST=`/usr/bin/hostname`
export CRONDIR=/app/cron
export CRONFILE=${CRONDIR}/${HOST}.cron
export CRONUSER=`who am i | awk '{print $1}'`
export LOGFILE=/var/adm/messages
export CURRENTCRON=/var/spool/cron/crontabs/root
if [ $USER != "root" ] || [ $CRONUSER != "root" ]
then
echo "The following message came from S99cronbuild:"
echo "Can't create cron file with other user then root."
echo "Exiting...";
exit 1
fi
if [ -f ${CRONFILE} ]
then
echo "Creating $CRONFILE as root cron file"
/usr/bin/crontab ${CRONFILE}
if [ $? != "0" ]
then
echo "The following message came from S99cronbuild:"
echo "The command crontab to ${CRONFILE} exited with error status."
echo "Please check ${CURRENTCRON} on ${HOST}."
exit 1
fi
exit 0
else
echo "The following message came from S99cronbuild:"
echo "${CRONFILE} does not exist."
echo "${CURRENTCRON} remains untouched."
exit 1
fi