user1723760
user1723760

Reputation: 1207

How to run crontab-e?

I am currently reading this documentation here where I want to use CRON. Now it says in the first section that I need to enter in a command: crontab -e.

Do I only need to enter this in a simple text editor file and just upload the file into the server?

I am using helios.hud.ac.uk so would this be the correct command:

* * 25 10 * helios.hud.ac.uk/u00000000/Mobile/inactivatesession.php

This will execute this php script below (inactivatesession.php):

<?php

include('connect.php');


$createDate = mktime(0,0,0,10,25,date("Y"));
$selectedDate =  date('d-m-Y', ($createDate));

$sql = "UPDATE Session SET Active = ? WHERE DATE_FORMAT(SessionDate,'%Y-%m-%d' ) <= ?";                                         
$update = $mysqli->prepare($sql);
$update->bind_param("is", 0, $selectedDate);
$update->execute();

?>

The url for this php script is: helios.hud.ac.uk/u00000000/Mobile/inactivatesession.php

I havn't used CRON before so just need little help on it.

Thanks

Upvotes: 4

Views: 153

Answers (2)

markus
markus

Reputation: 40695

  1. You open a shell (probably through SSH) to your server
  2. You run the command crontab -e
  3. You edit the crontab according to your needs (if you want to run a php script over http you need to use wget)
  4. You save and exit If you didn't make any mistakes, you will get a message that crontab was updated

Upvotes: 2

Jon
Jon

Reputation: 4736

If you are making a crontab that will access a remote webpage (which is what this is as it is not on your local server) you need to prepend the URL with wget

* * 25 10 * wget -O - http://helios.hud.ac.uk/u00000000/Mobile/inactivatesession.php

It will run the script on the server and output it to standard output (which in most servers will be emailed to you)

This assumes that you have a linux machine. crontab -e sets up a cron tab for your user account. So you can't really upload a crontab, but if you have cpanel or similar, most times you have access to cron from there.

Upvotes: 3

Related Questions