0

I have the following command in my crontab:

* * * * * root /home/amith/m.sh >dev/null 2>&1

where m.sh consists of:

#!/bin/sh
curl -0 "http://www.google.com" > /home/amith/Desktop/h2

but the command in shell script is not executing at all. Can anyone please tell me the solution?

2
  • is m.sh executable ? Also I would try with 1 * * * * instead of all *. Commented Mar 8, 2015 at 7:39
  • Yes it is executable.Okay I will try with that Commented Mar 8, 2015 at 8:22

2 Answers 2

1

First be sure that your script /home/amith/m.sh is running correctly! Your crontab entry is wrong you dont need root before script. Also your redirection to /dev/null is not good you are missing / before dev

You can set env varibale for SHELL in crontab with this

crontab -e
SHELL=/bin/sh

Then add your script:

* * * * * /home/amith/m.sh >/dev/null 2>&1
Sign up to request clarification or add additional context in comments.

Comments

0
* * * * * cd /full/path; sh m.sh;

First, change the directory into your file location (use cd). Then, bash it with sh command. Change * * * * * with the time schedule. To run the file every minute * * * * * To run every hour (1:00, 2:00, 3:00 and so on) use 00 * * * * To run everyday at 6 AM use 00 06 * * * To run the file on 9th March at 6 AM use 00 06 09 03 * The structure is minute hour date month day of week If you want to schedule it every Monday at 06 AM use this 00 06 * * 1 See this link http://www.pantz.org/software/cron/croninfo.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.