0

I want to Create the cron job, but everytime I do this step crontab -u Magento file system owner user name -e I got an error: must be privileged to use -u. The problem is I don't know what the Magento file system owner is. Where can I find this?

0

You can run ls -l to list the files in directory with user and group.

This will display something like this:

-rw-r--r-- 1 magentouser apache 691 Aug 2 13:54 acl.xml

Where magentouser is displayed will be your magento user.

I normally use su magentouser to switch the current user to the magento user and then run crontab -e to set up cron for that user.

0

Instructions for Windows

  1. First of all, find location of php.exe – Generally where Xampp is installed, it’s in Drive:\xampp\php e.g c:\xampp\php
  2. Go to a folder and create a file named magentocron.bat
  3. Edit this file and paste 3 lines shown below:

    php_path\php.exe magento_root\bin\magento cron:run
    php_path\php.exe magento_root\update\cron.php
    php_path\php.exe magento_root\bin\magento setup:cron:run
    

    For example, a finished version might look like this:

    C:\xampp\php\php.exe C:\xampp\htdocs\magento\bin\magento cron:run
    C:\xampp\php\php.exe C:\xampp\htdocs\magento\update\cron.php
    C:\xampp\php\php.exe C:\xampp\htdocs\magento\bin\magento setup:cron:run
    
  4. Save the file, open command prompt and enter following command:

    `schtasks /create /sc minute /mo 5 /tn Magento\Cron /tr path\to\bat\file\magentocron.bat`
    
  5. Now click on Start –> Control Panel –> Administrative Tools –> Task Scheduler.

  6. Expand Task Schedule Library from the left hand column and click Magento.
  7. Select Cron from the middle pane, click properties from the right pane under selected items.
  8. Under Security Options, click the Change User or Group button.
  9. Now in the current window, enter System username in the object name box and click check names. Click OK to close the User window, and OK to close the Cron properties Window, and close Task Scheduler.
  10. Cron job setup is successful and it will run every 5 minutes.

Instructions taken from here: https://magecomp.com/blog/set-up-magento-2-cron-in-xampp-windows/

This below assumes you are on *nix

Since you are trying to edit the crontab for another user, you need to use sudo

This is assuming your magento file system owner is magento

sudo crontab -u magento -e

You can also switch to that user, then set the crontab:

su magento then... crontab -e

What are the permissions set as in your deployment? What is the output of ls -la /path/to/your/magento?

Do you have a magento file system user? What is the output of id magento?

If you get something like this:

| => id magento
id: magento: no such user

Then you will need to create a magento user, and then set the permissions on your magento directory accordingly.

More information here: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html

  • When I use sudo, I got command not found – NielN98 Aug 11 '17 at 15:25
  • What is your OS? What stack are you using? What do you get from ls -la /path/to/your/magento? – nick.graziano Aug 11 '17 at 15:28
  • Also do you have a magento user? What is the output of id magento? – nick.graziano Aug 11 '17 at 15:35
  • I'm using Windows 10 and Putty – NielN98 Aug 11 '17 at 15:35
  • and I get id: magento: no such user – NielN98 Aug 11 '17 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.