0

I try to learn how to create crontabs in a remote server.

I try to run a script every 5 minutes.

I use a server in the company "IONOS" and it is in Europe.

I have a Mac. I open the Terminal.

# I go to the server with the authentification. It works well: 
ssh userName@serverName

# I open the default editor. That is Vim:
crontab -e

# I edit the file:
i

# I give my email. If the Cron fails: 
MAILTO=info@example.com 

# Every 5 minutes go to a file where I have a simple script that sends me an e-mail:
*/5 * * * * http://www.example.com/cron-test/1.php  

# save and exit the file
:wq

The Cron does not work. I have received that error in the email that I provided:

/bin/sh: 1: https://www.example.com/cron-test/1php: not found

In that message, the address is a link and the last ":" is included in that link. I do not know if that could be the problem?

Of course, I have checked that if I go to https://www.example.com/cron-test/1php it works well and sends me an email with php.

Please, be aware that I am new to Cron and new with the Terminal. I am just learning and making tutorials.

Nrc
  • 101

1 Answers1

0

Wikipedia states: "The software utility cron is a time-based job scheduler[..]. Users that set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run [..]."

So, your server is configured to run a command/script every 5 seconds that is named:

'http://www.example.com/cron-test/1.php'

In other words: somewhere within your $PATH an executable command with above name should be found, so that "/bin/sh" could execute this command and send STOUT to your email address.

You have merely provided a URL, but the server doesn't know what you want to do with it.

I think what you try to achieve can be resolved with:

*/5 * * * * /usr/bin/lynx --dump http://www.example.com/cron-test/1.php 

This tells the server to use the lynx command with the --dump option to get the contents of www.example.com/cron-test/1.php and email it to you.

(Execute textbrowser Lynx and dump content of rendered webpage example.com/cron-test/1.php into email to above mentioned address).

John
  • 28