Victor Ferreira
Victor Ferreira

Reputation: 6449

Can't make crontab work

I am new to Linux and Ubuntu and I seldom have to use it. I am trying to make this PHP script to run every minute using cron, but firstly I wanted to make some tests.

I created an empty file at /var/www/html/ called test. I ran on terminal:

sudo crontab -e

And added this line:

0 * * * * rm /var/www/html/test

Then saved it and exited. It said "Installing new Crontab"

Nothing happened. Then I created a file bfile.sh that contained:

#!/bin/sh 
rm /var/www/html/test

and added the following to crontab:

0 * * * * bash /var/www/html/bfile.sh

Still nothing happened.

What do I have to do to see anything happening from crontab? By the way I checked and the service is running

Upvotes: 3

Views: 108

Answers (2)

Karthik K
Karthik K

Reputation: 243

0 * * * * runs once every 1 hour. If you want to run every minute it should be */1 * * * *

You can also check the /var/log/cron file for any errors

Upvotes: 3

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136208

0 * * * * basically says "run this at 0th minute of every hour."

If you need cron to run your command every minute do * * * * *.

Upvotes: 3

Related Questions