Need some help with crontab
-
I'm accessing the crontab file using my user, with sudo access. Below is the entire crontab file.
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed * 15 * * 1 /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts ~ ~ ~ ~ ~ ~ "/etc/crontab" 15L, 533C
-
@dustinb3403
Maybe its something to do with the mailto variable. -
I just changed the job to include my username. We'll see how that goes.
-
@black3dynamite said in Need some help with crontab:
@dustinb3403
Maybe its something to do with the mailto variable.I don't think that is the issue, as I didn't add that. The only part I added was the command.
I configured this to run at 11AM EST (16:00 UTC) and will report back a few minutes.
-
@dustinb3403 /usr/bin/php isnt a user. I think you need to quote up.
-
@momurda said in Need some help with crontab:
@dustinb3403 /usr/bin/php isnt a user. I think you need to quote up.
So ?
@weekly "/usr/bin/php" "/var/www/html/snipeit/artisan snipeit:expiring-alerts"
-
@dustinb3403 said in Need some help with crontab:
"/usr/bin/php" "/var/www/html/snipeit/artisan snipeit:expiring-alerts"
trying this
10 16 * * 1 "/usr/bin/php" "/var/www/html/snipeit/artisan" "snipeit:expiring-alerts"
-
That didn't work. . .
-
@dustinb3403 said in Need some help with crontab:
That didn't work. . .
Have you tried that command under root crontab?
-
@black3dynamite said in Need some help with crontab:
@dustinb3403 said in Need some help with crontab:
That didn't work. . .
Have you tried that command under root crontab?
Stepping into su and running the command words.
su root > pass /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts
So this has to be with the way I have it configured. I wonder if I need to create a bash script, and simply have cron call that rather than using the lines like above in cron. . .
If I do then the documentation is misleading. . .
-
I've created a simple script and have cron set to run the script at 11:35AM. So I'll see if that works.
Executing the script from SSH works without issue. . .
So we'll see. . .
-
Ok and that is what it was.
Simply needed to make a bash script out of it and have it scheduled to run, rather than using the commands directly in cron.
Problem solved.
Solution:
pwd /usr/bin/local touch expiring-alert.sh vi expiring-alert.sh /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts sudo vi /etc/crontab 35 * * * 1 <user> /usr/local/bin/expiring-alert.sh
Presumably changing this to be
@daily
or@weekly
would work as well. -
@dustinb3403 said in Need some help with crontab:
Ok and that is what it was.
Simply needed to make a bash script out of it and have it scheduled to run, rather than using the commands directly in cron.
Problem solved.
Solution:
pwd /usr/bin/local touch expiring-alert.sh vi expiring-alert.sh /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts sudo vi /etc/crontab 35 * * * 1 <user> /usr/local/bin/expiring-alert.sh
Presumably changing this to be
@daily
or@weekly
would work as well.MOst of the time that is how I have it setup on my crontab, same for my certbot scripts too.