Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: Cant run cron job as www-data

  1. #21

    Re: Cant run cron job as www-data

    I opened astarmathsandphysics.log an emptied the contents then saved it without starting rsyslog.
    Then I ran
    sudo /usr/bin/google-sitemapgen --config=/usr/share/doc/google-sitemapgen/examples/astarmathsandphysics.xml

    and log file was empty when the command finished executing. Probably the script does not write to the file.

  2. #22
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Cant run cron job as www-data

    Quote Originally Posted by astarmathsandphysics View Post
    I could but I thought it would be bad practiice to have a file owned by root accessible via the internet.
    Not really. All Google does is download the file. Also the file won't be executable.

    If you're really paranoid about this, run the script as root and include
    Code:
    chown www-data:www-data /path/to/the/file
    chmod 444 /path/to/the/file
    at the end of the script.
    Last edited by SeijiSensei; August 22nd, 2016 at 06:54 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #23

    Re: Cant run cron job as www-data

    I will execute as root and have written another cron job to change owbership of all files in /var/www to www-data:www-data once a week.
    Once is not enough because the script generates more files periodically and these are owned by root.

  4. #24
    Join Date
    Oct 2013
    Location
    Colorado
    Beans
    560
    Distro
    Xubuntu 20.04 Focal Fossa

    Re: Cant run cron job as www-data

    Quote Originally Posted by astarmathsandphysics View Post
    I will execute as root and have written another cron job to change owbership of all files in /var/www to www-data:www-data once a week.
    Once is not enough because the script generates more files periodically and these are owned by root.
    So you have the script running successfully as a cron job now?

  5. #25
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Cant run cron job as www-data

    Quote Originally Posted by astarmathsandphysics View Post
    I will execute as root and have written another cron job to change owbership of all files in /var/www to www-data:www-data once a week.
    Once is not enough because the script generates more files periodically and these are owned by root.
    I was speaking more about writing a "wrapper" script that invokes the Google map generator and then changes the ownership. Something like this:
    Code:
    #!/bin/bash
    MAP=/path/to/the/map.xml
    
    chown root:root $MAP
    chmod 600 $MAP
    
    /usr/bin/google-sitemapgen --config=/usr/share/doc/google-sitemapgen/examples/astarmathsandphysics.xml
    
    chown www-data:www-data $MAP
    chmod 444 $MAP
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  6. #26

    Re: Cant run cron job as www-data

    I will try that

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •