-5

I am trying to add a new script to crontab using putty. I am following these steps:

  • open putty
  • enter my username / password
  • enter command crontab -e to create new crontab
  • copying this command to putty by right click */1 * * * * var/www/servername/html/populate_data_nrgrs.php
  • hit esc key then enter :wq press enter
  • I am getting a message installing crontab

Then after 15 minutes nothing happens. I entered the command crontab ~l It says:

[asingh@cs1 ~]$ crontab ~l
~l: No such file or directory
[asingh@cs1 ~]$

I tried to include the username at the begining of my script */1 * * * * asingh/var/www/servername/html/populate_data_nrgrs.php with no success.

Deer Hunter
  • 1,070
  • 7
  • 17
  • 25
  • Highly recommended: http://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it – Deer Hunter Sep 11 '14 at 03:45
  • 1
    You're typing a tilde instead of a dash. The command to see your crontab is `crontab -l`, not `crontab ~l` – Jenny D Sep 11 '14 at 06:38

3 Answers3

5

Replace the crontab line with

* * * * * php /var/www/servername/html/populate_data_nrgrs.php

Some issues:

  • You missed the first / for the full path
  • The list command is crontab -l, not crontab ~l
  • The form */1 is redundant, because * alone means "every minute". It makes sense for something like */15 for "every 15 minutes"
  • The username is entirely wrong in your last line
  • I omitted the () pair when editing your post. If they where in your crontab, that's wrong.
  • I overlooked that it's a PHP file. You likely can't run it directly but have to feed it to the php CLI binary. I added that to the command above.
Sven
  • 97,248
  • 13
  • 177
  • 225
1

If **(*/1 * * * * var/www/servername/html/populate_data_nrgrs.php)** is exactly command data you are using, you need to put a slash before the var directory like that:

(*/1 * * * * /var/www/servername/html/populate_data_nrgrs.php)

If the problem persists, you could use the php command to execute the script.

*/1 * * * * **php** /var/www/servername/html/populate_data_nrgrs.php
ThoriumBR
  • 5,272
  • 2
  • 23
  • 34
0

As SvW says you had several problems with the command. Next time, if you want to see why crontab is not being execute, add to the very first line of the crontab"

MAILTO=youremail@yourdomain.com

If the server is capable of sending emails, you will receive an email with the output of the command, including the error if happens.

Tk421
  • 220
  • 1
  • 8