Reputation: 1006
everyting working as root user in linuxmint. my bashscript works perfectly as a single script and generating logfile as well but it is not getting invoked in my current shell through crontab.
path of bashscript: /root/Documents/mybashscript.sh
crontab line:
0.9 * * * * root /root/Documents/mybashscript.sh > /root/Documents/crontab.log
mybashscript.sh inside commands are as below:
#!/bin/bash
source /root/.profile
echo -n "Please enter your name: "
read name
TIME=‘date +%H‘
case $TIME in
0[6-9] | 1[01] ) echo -n "Good morning";;
12 ) echo -n "Good Noon";;
1[2-6] ) echo -n "Good Afternoon";;
1[7-9] ) echo -n "Good Evening";;
*) echo -n "Good Night";;
esac
echo " $name, Nice to meet you!"
Can anybody tell me how to trouble shoot.
Upvotes: 0
Views: 100
Reputation: 881573
First things first, I don't believe 0.9
is a valid minute indicator. I think you probably want 0-9
(depending on when you want it to run of course).
Secondly, you appear to have an extraneous root
in your cron
entry (the first one following the final *
).
Thirdly, cron
jobs don't really work that well for interactive input like:
read name
so I'm not sure what you're trying to achieve there.
Upvotes: 1