1. Home
  2. Docs
  3. FAQs
  4. Frequently Asked Question...
  5. How can I execute a custom PHP file via Cron on a server with multiple subdomains?

How can I execute a custom PHP file via Cron on a server with multiple subdomains?

You can follow these steps to set up and execute your custom PHP file via Cron:

  1. Add Execution Permission:
    To ensure your PHP file is executable, you need to adjust the file’s permissions. Run the following command to make the PHP file executable within your Docker container:
    docker compose -f /home/fly/domain.com/docker-compose.yml exec php bash -c "chmod +x public/example.php"
  2. Verify Permissions:
    After setting the correct permissions, you should check to confirm that the changes have been applied. Use this command to list the file and its permissions:
    docker compose -f /home/fly/domain.com/docker-compose.yml exec php ls -lah public
  3. Execute the PHP File (and Add to Cron):
    Once the permissions are set, you can execute the PHP file manually. This command can also be added to your Cron Jobs for scheduled execution:
    docker compose -f /home/fly/domain.com/docker-compose.yml exec php php public/example.php

Note: Be sure to replace domain.com with your actual domain and example.php with the name of your PHP file before running these commands.

If you encounter any difficulties or need further assistance, please create a support ticket. Our team will be happy to handle the setup for you.