Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:48:45+00:00 2026-06-15T02:48:45+00:00

I need help executing a php script via CLI. Not sure if this is

  • 0

I need help executing a php script via CLI. Not sure if this is a Linux or PHP problem.

When I execute /usr/bin/php /var/www/backup.php in Ubuntu I get:

You are not permitted to execute this script

The code in backup.php is:

<?php

// Set default paths
define ("DOCUMENT_ROOT","/var/www");
define ("DATABASE_PATH","/var/lib/mysql/livedb");
define ("BACKUP_PATH","/var/sitebackups");

$filename_suffix = "_" . date("Ymd_his") .".tar.gz";

if ($_GET['key']!="xxx") {
        die ("You are not permitted to execute this script");
}

//change working directory to backup directory
if (!chdir(BACKUP_PATH)) {
        die ("Failed to change to working directory.");
}

// Tar the web files
$cmd = "tar -cvzf " . BACKUP_PATH. "/webfiles" . $filename_suffix . " " .DOCUMENT_ROOT ;
echo $cmd . "<br/>";
//echo shell_exec($cmd);

// Create link to web files backup

// Tar the mysql DB
$cmd = "tar -cvzf " . BACKUP_PATH. "/dbfiles" . $filename_suffix . " " .DATABASE_PATH ;
echo $cmd . "<br/>";
//echo shell_exec($cmd);

// Move to backup folder

// Create link to DB backups

// Email backup confirmation

?>

I even tried to add this is a scheduled task via crontab and I still get the same error in the logs.

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:48:47+00:00Added an answer on June 15, 2026 at 2:48 am

    I can’t see a problem at all. The code is working correct.

    The variable $_GET['key'] isn’t set in CLI and is always not the same as ‘xxx’, so the code stops by printing out your string.

    Delete the if-clause and the code will do the rest, if permissions on files and folders are set correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
I need help with posting a value to a php script from a js
Good day everyone I need to execute command on linux machine this command is
Thanks in advance, I need help in solving php memory problem, I have created
I'm in need for php help/expertise to tweak/change this preg_match_all function. What I want
Please I need help getting the exact md5 value of this python script in
I need help with one of the Groovy 1.8 DSL features. Consider this test
I am not sure this is even possible, but I am hoping for a
I have a shell script which is executing a php script (worker for beanstalkd).
I need your help., How to pass the array values in query string... <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.