Creating Cron Jobs

Guys, I have an issue I have not been able to figure out. I’ve been trying to schedule a Cron Job and I can’t find a way for it to fire. It used to show Start/Stop when testing on shell, but now all I get is NO OUTPUT GENERATED… I’m trying to set up CJ from my CRM using this string:

sh /home/USER/CRM URL/cron/vtigercron.sh

But, I can’t seem to make it work. Would any one have any suggestions and how it would work?. It used to work like this. Thanks

C7
Operating system:
OS version:

None knows?..

O.K. I’m beginning to think this is a bug in Webmin. By searching on this topic, no one seems to have reported this. I’ve tried several ways to get this to work and no luck. Logs do not show any errors. I see email in root directory. This was never an issue before.

That’s not a problem I’ve seen.

You can check the crontab that Webmin produced (which crontab it appears in depends on the user and type of job) to be sure it’s reasonable. Most are in /etc/cron*, but user crons live in files in /var/spool/cron.

Usually when I find a cron job isn’t working, it’s because the script can’t run with the environment cron has.

Thanks Joe. /etc/cron* doesn’t exist. /var/spool/cron has these cronjobs.

@hourly sh /home/USER/domains/URL/public_html/cron/vtigercron.sh

          • sh /home/User/domains/URL/public_html/cron/vtigercron.sh

but no errors…

there are some generated by the server running fine. The last two I’m trying to run… I never had this issue before using the same path.

Asterisk (*) is a wildcard. I don’t mean there is literally a file called cron*.

I have /etc/cron.d and it generated 0hourly, clamav.update and sa.update. Nothing relevant

Try running a simple touch testfile job in the place of the script. That’ll confirm the job is firing.

Also, check the cron log in /var/log/cron.

How do I do that?

Hi Joe, upon inspection of /var/log/cron I see several strings as this in yellow:

ul 12 02:01:01 ns10 run-parts(/etc/cron.hourly)[27216]: starting awstats
Jul 12 02:01:01 ns10 anacron[27234]: Anacron started on 2021-07-12
Jul 12 02:01:01 ns10 run-parts(/etc/cron.hourly)[27242]: finished awstats

But, the ones I’m testing show in white without Starting/Finished

Jul 12 11:33:01 ns10 CROND[14575]: (root) CMD (sh /home/USER/domains/URL/public_html/cron/vtigercron.sh)

Do you any other suggestions?. TY

I try running it with this:
run-parts /etc/cron.daily

And I got this back:

Jul 12 11:42:21 ns10 run-parts(/etc/cron.daily)[16917]: starting 00webalizer
Jul 12 11:42:21 ns10 run-parts(/etc/cron.daily)[16924]: finished 00webalizer
Jul 12 11:42:21 ns10 run-parts(/etc/cron.daily)[16917]: starting logrotate
Jul 12 11:42:21 ns10 run-parts(/etc/cron.daily)[16931]: finished logrotate
Jul 12 11:42:21 ns10 run-parts(/etc/cron.daily)[16917]: starting man-db.cron
Jul 12 11:42:22 ns10 run-parts(/etc/cron.daily)[16942]: finished man-db.cron
Jul 12 11:42:22 ns10 run-parts(/etc/cron.daily)[16917]: starting mlocate
Jul 12 11:42:26 ns10 run-parts(/etc/cron.daily)[16986]: finished mlocate

It’s running, but for some reason the ones I need are not.

Wow. How is this so complicated?..

cron.daily runs jobs in /etc/cron.daily. And, I guess your job is not in cron.daily. There are many cron locations.

It’s just cronjobs, as they’ve always been. We don’t touch the cron implementation…you’re dealing with the standard stuff.

I suspect your script doesn’t do what you think it does. You see it running in the cron log, right? So we know the cron scheduling portion of things is right. The only thing left is a problem with the script or a problem with the environment in which the script runs. Is the file executable? Does it expect things to be in the PATH that cron won’t have setup? Any other environment dependencies?

If it were me, I’d add some logging to the script to make sure it’s actually starting and then see where it’s failing.

My problem is that this used to run properly. the file has 755.

I would think that the problem is that it no longer does. :wink:

LOL… Are there any other scripts to install to run Cron?

I don’t think I understand the question. cron is part of your OS. It’s there before we even get installed.

You should be troubleshooting your script, not cron. You see the command run in the cron log; you know cron is doing its job. The problem you need to solve is why the script doesn’t do what you expect it to when it is run by cron.

I note that the command is being run as root, which seems maybe wrong? Maybe it should run as whatever user does vtiger things? (I dunno. I dunno how you set this up or what it’s supposed to do.)

But, again; the most common problems with scripts that work when you run them yourself from the command line but don’t when run from cron are that the environment is wrong (wrong user, wrong PATH, some missing library path, etc.) or the permissions are wrong (again wrong user).

So, to confirm: The script works when you run it yourself from the command line, right? That’s the first troubleshooting step, always.

The script doesn’t run at all.

Then why the heck are we talking about cron?