2

Well I am new to the term CRON. What I know about this, it is a Unix concept to schedule particular operation to be executed after a defined time interval.

I need to run a php file, to update database once every hour. But my confusion is with scheduling the execution. I am using XAMPP for local development test on Windows 7.

What I found:

In all the above links, they are saying to configure a cron job on linux shell level. So is it, that the cron is on OS level and not on application level program.

If yes, then how can I create a cron in php on a shared hosting.? If I do not have access to the command line, then I cannot create a Cron job for php.?

If no, then how?

In all the above example I found one similar fashion of code:

0 * * * *     cd C:/xampp/htdocs/plugins/moviefeed/ && php cron.php

What is this * for?

Community
  • 1
  • 1
Veer Shrivastav
  • 5,434
  • 11
  • 53
  • 83
  • 2
    There's no CRON in windows. You need Task Scheduler. Yes it's on OS Level, asterisk in cron means anytime. http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800. It consist of five parts It consists of five parts: minute, hour, day of month, month, day of week – kimbarcelona Aug 11 '14 at 05:49
  • That `0 * * * *` stuff is indeed your CRON settings, each of those * has a meaning of time; the first is for years to run, if you leave it * it will run every year while 2 would run it every 2 years and so on. – Azrael Aug 11 '14 at 06:00
  • So can't I register a Unix cron from my php code.? – Veer Shrivastav Aug 11 '14 at 06:53
  • Not sure of what you mean with "OS level" and "application level". You're probably used to web applications and are confused by the fact that Apache does not play any role here. Key concepts are "HTTP" and "command-line"—cron uses the second one. – Álvaro González Aug 11 '14 at 07:37

1 Answers1

2

Obviously you set crons at OS level not at Application level. Although, Like on Unix/Linux, You can set CRON at windows platform too by using Task Schedular ( All Programs->Accessories->System Tools -> Task Schedular ). I think you should go for VPN or Dedicated Servers for crons to set as it needs access to system resources privately.

Apart from it, Syntax for Crontab command(unix/linux) goes like this:

1 2 3 4 5 /root/backup.sh
1: Minute (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command - Script or command name to schedule
Vivek Pratap Singh
  • 9,326
  • 5
  • 21
  • 34