How to configure crontab to run URL, Linux Ubuntu command

Asked

Viewed 1,187 times

6

I created 4 methods and I want to run them by accessing the link. I have already tested the methods and all are working normally, but I have tried several settings by crontab -e.

I’ve tried to:

0 * * * * wget http://meusite/rota

0 * * * * curl http://meusite/rota

I’ve used tbm -the minuscule and capitalize, and I’ve tried also using the path of my project, example:

0 * * * * curl /var/www/projeto/rota

0 * * * * wget /var/www/projeto/rota

Note: I am doing the configuration by root. Another thing, there is a command to check if it is working, and how do I set to receive an email every time you run.

My command executes a method where it loads user data, in that method does not pass any parameter as it fetches all users

I used the debug command to see what is happening:

DEBUG output created by Wget 1.12 on linux-gnu.


--2016-02-11 16:40:01--  http://caminho/cron
Connecting to 162.243.102.127:80... connected.
Created socket 3.
Releasing 0x0000000000b80c90 (new refcount 0).
Deleting unused 0x0000000000b80c90.

---request begin---
GET /blksocial/cron/follow HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 162.243.102.127
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.0 500 Internal Server Error
Date: Thu, 11 Feb 2016 18:40:03 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Cache-Control: no-cache, private
Connection: close
Content-Type: text/html

---response end---
500 Internal Server Error
Closed fd 3
2016-02-11 16:40:01 ERROR 500: Internal Server Error
  • Before anything you need to check this 500 error returned by server.

  • If the answer below has helped you, please click on the check mark next to the reply to mark it as accepted.

  • Is the error shown error 500? Error 500 is server-side, not client-side. Even putting the path of the executable (which is recommended) in cron, this would not change the error

2 answers

1

Just one note, you should run the Url with no output or progress, channeling to / dev / null like this: Example running every 5 minutes.

 */5 * * * * curl -s http://meusite/rota > /dev/null

 */5 * * * * wget http://meusite/rota

Note: The alias must exist to execute the command without the full path. Ex: /usr/bin/Curl

This site can also help you in the matter of time: https://crontab.guru/

:)

0

Victor, do with the following command:

0 * * * * /usr/bin/curl http://meusite/rota

You said in your question that you used Curl, but I saw that you put only the command, so I think it would be the case to include Curl’s Path.

  • 7

    It would be interesting for you to briefly explain what the command does, so your answer becomes more complete.

  • My command executes a method where it loads user data, in this method I do not pass any parameter, because it searches all users.

  • @Victorrajesh did not understand your comment about passing parameters or not, I just put in my reply the command with the Curl Path that you said you had used but unsuccessfully.

  • I wanted to explain that it is only a simple method, which if called by the URL works as I want. You would have to release some permission before running crontab?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.