2

Tryin to configure for two running applications on my server, two CronJob.

The command I have to place on ConrJob is:

wget -q -O- http://myDOMAIN/cron/index

I've done already:

crontab -e

Edits on the file:

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/1 * * * * wget -q -O- http://myDOMAIN/cron/index
*/1 * * * * wget -q -O- http://myDOMAIN2/cron/index

But I'm not receiving a successfully mail notification from APP. In Maildir folder /home/master/ (own mailserver) I just got following message:

Return-Path: <master@myDOMAIN>
X-Original-To: master
Delivered-To: master@myDOMAIN
Received: by myDOMAIN (Postfix, from userid 1000)
    id 0DA2F1A1F2B; Fri, 16 Jun 2017 16:42:01 +0200 (CEST)
From: root@myDOMAIN (Cron Daemon)
To: master@myDOMAIN
Subject: Cron <master@node01-ubuntu> /myDOMAIN/cron/index
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20170616144201.0DA2F1A1F2B@mmyDOMAIN>
Date: Fri, 16 Jun 2017 16:42:01 +0200 (CEST)

/bin/sh: 1: /myDOMAIN/cron/index: not found
7
  • /bin/sh: 1: /myDOMAIN/cron/index: not found Seems to implicate that your wget commands aren't working correctly. Have you tested them outside of cron? Jun 16, 2017 at 14:58
  • @BrianSizemore, how to do that?
    – Gianni
    Jun 16, 2017 at 14:58
  • 1
    Just open up a shell and run the cron command you are attempting to do. Eg. open shell and run wget -q -O- http://myDOMAIN/cron/index See if it works successfully or fails with an error. It appears that your cron IS running, just not succeeding since it's printing some errors from bash. Jun 16, 2017 at 15:00
  • connecting to server (SSHing form Terminal) executing the wget command, nothing happend... no new mail on my Maildir folder, nor happend something if I run che wget command form application manually.
    – Gianni
    Jun 16, 2017 at 15:02
  • Sorry overlooked something. Remove the -q flag from the wget command. That is the "quiet" flag which will hide useful output. Jun 16, 2017 at 15:04

2 Answers 2

1

cronjobs need the full path: try
/usr/bin/wget -q -O- http://myDOMAIN/cron/index
or
/usr/bin/wget -q -O- http://myDOMAIN/cron/index 2> $logfile
and add $logfile to your mail

0

You can use a script for this (for example, a script like cron.sh):

Inside your script, add all the behaviors you want to run:

#!/bin/bash
wget -q -O- http://myDOMAIN/cron/index
wget -q -O- http://myDOMAIN2/cron/index

then chmod a+x /path/to/croh.sh

Finally, add the following to your crontab:

*/1 * * * * /path/to/croh.sh

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.