I am working on cent-OS server. I have two scripts to run by cron. Scripts are in PHP and i have a Apache module of PHP installed on cent-OS. One Script should run everyday at 6pm and other on every Thursday. My cron commands are:

00 18 * * * lynx -dump http://domain/folder1/script1.php //every Day

00 02 * * 5 lynx -dump http://domain/folder1/script2.php //every Thursday at 2am

i wrote both the lines in my /etc/crontab file and tried to execute it from

[root@domain ~]# /etc/crontab crontab
-bash: /etc/crontab: Permission denied

Searched online but no solutions. Any ideas what i am missing?


crontab is not an executable file. It is used by cron to know when the jobs should be scheduled.

/etc/crontab is not executable (hence the error)

Your crontab file is invalid (comments in C or Java style ere not allowed):

from the man page:

Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as cron commands, since they will be taken to be part of the command. Similarly, comments are not allowed on the same line as environment variable settings.

You should write something like:

# every day
0 18 * * * lynx -dump http://domain/folder1/script1.php > /tmp/somefilename

Notice that lynx -dump will just print the page to standard output. If you want to store it somewhere you need to redirect the output to a file (see example)

To see if it works wait until 00:18 or use a time nearer in the future for testing purposes

| improve this answer | |
  • Thanks Matteo for the help and for explaining this to me. – Astha Nov 11 '11 at 11:18

Any ideas what i am missing?

Not much. You entered a wrong door in a wrong city and talked to a wrong person on a wrong day. Other than that, everything went as expected. ;-)

1) You should not comment your crontab lines by appending // at the end of line. Instead, do it like this:

# every day
00 18 * * * lynx -dump http://domain/folder1/script1.php

# every Thursday at 2am
00 02 * * 5 lynx -dump http://domain/folder1/script2.php //every Thursday at 2am

2) You scheduled the tasks run every day at 18:00 and every Thursday at 2am. If you try to run crontab outside of those time windows, cron will only check if it has something to do and if it does not, it just exits.

3) Did you check from /var/log/cron if cron tried to run your scripts during the scheduled times?

4) Cron is picky about paths. Try to provide a full path to lynx, most likely in your case /usr/bin/lynx.

5) As mentioned by others, /etc/crontab is just a text file and not an executable. Cron daemon will check the contents of /etc/crontab and per-user cron files and will execute something, if it is time to do so.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.