Running the curl command using CRON jobs

I want to run this statement:

curl 'http://localhost:8983/solr/dataimport?command=full-import' 

every 10 minutes using CRON jobs.

How do I achieve this?

+4
source share
3 answers

Sort of:

 crontab <<'EOF' SHELL=/bin/bash #min hr md mo wkday command */10 * * * * curl 'http://localhost:8983/solr/dataimport?command=full-import' EOF 

Use crontab -l to look at it later. BUT, add a parameter to this curl command to put the output somewhere specific, since it can be run somewhere that you do not have write access to. Also, if curl unusual somewhere, you may need to specify its full path, for example /usr/bin/curl , or set the crontab PATH variable.

The quotes around the EOF prevent the HEREIS document from being replaced (all between <<EOF and EOF). HEREIS documents are a shell feature, not part of EOF). HEREIS documents are a shell feature, not part of crontab`.

See man 5 crontab for a detailed description of what happens in crontab files.

Usually I save the ~/.crontab for editing with a special first line, and the execution bit:

 #!/usr/bin/env crontab SHELL+/bin/sh [... etc.] 

This allows me to edit my ~/.crontab and then just run it with:

 $ vi ~/.crontab $ ~/.crontab 

(I also usually have extensions to indicate which host they are for, e.g. ~ / .crontab.bigbox)

+7
source

In case of using Cpanel:
Cpanel-> Cron Jobs-> Put Time Interval (* / 10 * * * *)
Add a command to the text box:
curl -s "http://localhost:8983/solr/dataimport?command=full-import"
where -s means silence (no output)
You finished

+3
source

For a server with a blue host and go daddy:

 curl -s "http://localhost:8983/solr/dataimport?command=full-import" 
0
source

Source: https://habr.com/ru/post/1493364/


All Articles