How to run a PHP file when starting Fedora 25

0

How can I run PHP automatically when I start Fedora 25 Desktop ?

I choose to execute:

php /var/www/asterisk-connector.php

Whenever I start Fedora 25 and it does not stop running, this file always stays connected with my Asterisk switch waiting for events, the idea is that if the light as soon as I return start the server and execute the script PHP How can I do it step by step?

    
asked by Alejandro Godinez 28.01.2017 в 21:57
source

1 answer

0

Cron or demon ...

They are scheduled tasks that are in constant execution depending on their configuration.

First check if you already have cron system installed and running

/sbin/service crond status

If you do not have the service install it with the following command.

rpm -q vixie-cron

For the configuration the main cron configuration file, / etc / crontab , contains the following lines:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

The first four lines are variables that are used to configure the environment in which cron tasks are executed. The SHELL system variable that tells the shell environment to use (in this example, the bash shell), while the PATH variable defines the path used to execute commands . The output of cron tasks will be sent by email to the user name defined with the variable MAILTO . If the variable MAILTO is defined as an empty string (MAILTO=""), the email is not sent. The variable HOME can be used to set the main directory to use when executing commands or scripts.

Each line in the / etc / crontab file represents a task and has the following format:

minute   hour   day   month   dayofweek   command

Here you can configure a .sh file and within it you can execute a series of commands including the call to the PHP script and set dates and execution time.

To start the CRON / sbin / service crunch start and to stop them / sbin / service crond stop

    
answered by 02.02.2017 в 17:51