0
My script is located in /opt/restart-hlasic.sh
restart-hlasic.sh contains:
#!/bin/bash
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/
SERVER="XXX"
TOEMAIL="XXX@XXX"
FROMEMAIL="XXX@XXX"
# Line divider
DL="~~~~~~~~~~~"
# Put the email together
BODY="${DL}
`date`
${DL}
Server byl restartovan
"
echo "${BODY}" | perl -e '($_ = join "",<>) =~ s/(\t)/ /g; print;' | sendEmail -f "${FROMEMAIL}" -u "${SERVER} St$
If I run script manually, mail is sent to me, but when I restart server, crontab doesn't run this script.
crontab -e
@reboot /opt/restart-hlasic.sh
I think that this is correct, or am I wrong? Thank you for help.
1The
expand
command is probably a better way to expand tabs; your perl command replaces each tab with a fixed number if spaces, which is not usually what you want. Where is thesendEmail
command? – Keith Thompson – 2013-04-10T19:42:39.390#!/bin/bash
is wrong, it will be executed bysh
, but I don't think that's your problem. – tripleee – 2013-04-10T19:47:40.4331You say the script is
kontrola
, but the cron job runsrestart-hlasic
. Are you confused, or are you omitting something? – tripleee – 2013-04-10T19:49:36.413@tripleee: The command in the
crontab
is executed bysh
, but the command is/opt/restart-hlasic.sh
which has#!/bin/bash
, so the command executed bysh
is effectively/bin/bash /opt/restart-hlasic.sh
. – Keith Thompson – 2013-04-10T23:07:11.520