Annon
Annon

Reputation: 48

How to run PHP Code from command line on linux Server

How can i run PHP Code from command line on Linux Server.

I have code which is a PHP Code I need to run that On linux as a cronjob.

Upvotes: 2

Views: 1998

Answers (2)

MangeshBiradar
MangeshBiradar

Reputation: 3938

Run PHP code from command line on Linux:

$php code.php

Add PHP file to run as a cron job:

$crontab -e

Add the schedule to cron.

Ex:

1 0 * * *  /usr/bin/php /var/www/code.php > /dev/null 2>&1

Upvotes: 3

Asghar
Asghar

Reputation: 2346

You can Use PHP CLI to run your code.

Like

$php -q /var/www/code.php

and using crontab -l and crontab -e command you can setup cronjobs.

Upvotes: 1

Related Questions