I need to run an script every 10th and 25th day in every month at 11pm.
the script name is
/home/ss/automated.sh
I tried to execute the script every day and everytime with the below syntax. its not executing it from crontab.
* * * * * /home/ss/automated.sh
Any idea why it not executing the script.
can you please let me the syntax for this request.
sea
March 25, 2015, 8:22am
2
cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
hth & Cheers
I am getting the below message.
I have setup the same by giving crontab -e. but the script is not executing it.
cat /etc/crontab
cat: Cannot open /etc/crontab: No such file or directory
---------- Post updated at 08:40 AM ---------- Previous update was at 07:41 AM ----------
please find my test below.
cat test.sh
#!/bin/ksh
date > /tmp/kk.txt
crontab -l | grep "test.sh"
39 * * * * ./tmp/test.sh
But this doesn't work
sea
March 25, 2015, 10:03am
4
Dont use relativ paths within crontab, use absolute paths instead. (as in your initial post)
hth
EDIT:
Or add the PATH env to crontab, put the script in such a path and just execute the script. (so the theory)
Either way, you have to make sure the script has execution flag set.
I am not sure how to add the PATH env to crontab ?
How to set the flag set ?
Please help me out.
sea
March 25, 2015, 10:33am
6
Use crontab -e
to add something like:
PATH=/path/to/:/usr/bin:/bin:/sbin
As for the execution flag:
chmod +x ./script.sh
However, i recomend to just use the full path in crontab!
hth
RudiC
March 26, 2015, 6:02pm
7
@sea : full path not only in crontab, but in the script itself as well.
@ramkumar15 : "doesn't work" doesn't help. Be specific: did it start? If yes, did crash? If no, any output? any error msgs? filed? mailed?
@sea (post #2 ) that's a root crontab entry. Normal users' crontabs don't have the username.