2

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.

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.