Crontab function does not work

Asked

Viewed 139 times

1

I have a php script that performs (should at least) some recordings in a txt:

25 11 * * 1-5 wget -q --spider http://10.24.0.42/felipe_projetos/DD/CREATE_TABLE.NULL.IN.php

However, the recording does not take place. I suspected at first that the error was in PHP itself, but when I run the file directly in the browser the recording happens, I do not know if the commands are wrong because I use two other similar commands that work perfectly:

30 22 * * 1-5 wget -q --spider http://10.24.0.42/felipe_projetos/DD/CREATE_TABLE.NULL.php


00 7 * * 1-5 wget -q --spider http://10.24.0.42/felipe_projetos/Poc/ch_ch.php

I changed the file to have 777 permission thinking it might be some kind of lock, but it still didn’t work

2 answers

1


I know two ways to schedule tasks on Crom:

1 - execute the command crontab -e that opened a window giving a slight description of how you can schedule the tasks in cron, where you can simply paste your already created cron, at the end the window should look like this:

# 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
25 11 * * 1-5 wget -q --spider http://10.24.0.42/felipe_projetos/DD/CREATE_TABLE.NULL.IN.php

In this example there is no need to define a user.

2 - Edit or create your cron in /etc/crontab-d/meucron

vi /etc/cron.d/meucron

now paste your cron

25 11 * * 1-5 root wget -q --spider http://10.24.0.42/felipe_projetos/DD/CREATE_TABLE.NULL.IN.php

Note that in this second method I set a user to perform the action. After editing/creating your cron and saving it, restart crontab.

For this second method you must be root to create or edit files in /etc/cron. d/

0

Browser other questions tagged

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