Linux-Want to write a. Sh to replace the original run script with PHP xxx.php

Source: Internet
Author: User
It turns out PHP xxx.php to run this PHP script.

In the Linux system
Want to use./xxx.sh to replace the top

Do not know whether it is feasible?

Reply content:

It turns out PHP xxx.php to run this PHP script.

In the Linux system
Want to use./xxx.sh to replace the top

Do not know whether it is feasible?

feasible,

#!/bin/bash# author: gm100861PHP=/usr/local/php/bin/php$PHP youphpfilename.php

Do you want to execute the PHP script directly?

1.在xxx.php开头加上#!/usr/local/php/bin/php2.chmod +x xxx.php3. ./xxx.php

That's the kind of shell you're using.

If it's bash, it's not a good idea, just pass the file name to the shell and call PHP to run.

If it is zsh, you can edit the. ZSHRC, using the Alias-s command, to specify which command to execute when you enter *.php directly. For example:
Alias-s php= ' php ' #在shell输入 run when *.php
Alias-s php= ' vim ' #在shell输入 open when *.php
Alias-s php= ' php-l ' #在shell输入 *.php when checking for syntax errors

Yes, just like inside the shell script.php ***.php
You can also specify the execution time and period by crontab

http://segmentfault.com/q/1010000003731015/a-1020000003732913

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.