Problem with cron job

I put a .sh script in /etc/cron.daily but for some reason it won’t run. The script is executable and cronie service is running. The script is rclone job so it may not be run as root.

Without seeing the entry, there are only a few things I can say right now, but they may all be pertinent…:

  1. A cron daemon — whichever one it is — generally does not have the same $PATH variable as interactive user accounts. Commonly the $PATH is limited to /usr/bin. This means that any executable from outside of /usr/bin that the daemon must be able to invoke must be specified with its full filespec — i.e. the full path to the filename.

  2. A task that needs periodic execution as an unprivileged user should not be put in /etc/cron.*/, but instead should be in the user’s own crontab. See the documentation.

  3. When adding anything to /etc/cron.*/ or /etc/crontab, the daemon should be restarted to pick up the new configuration.

Hopefully these tips will put you on the right track. :man_shrugging:

Edit: Alternatively, you could create a user-level systemd timer.

1 Like

Is cronie available and has it been started?
systemctl status cronie

1 Like

It is possible than some error might be logged by cronie, for instance if the script doesn’t run properly. Perhaps use something like this and look for errors (or for confirmation the script is at least getting started):

journalctl -u cronie.service
1 Like

With a modern Linux like Manjaro, you’d probably be better off doing it as a systemd user timer. It has quite a steep learning curve, but once you’ve got the hang of it, it’s simple to use existing unit/timer files as templates whenever you need another one.
Systemd timers documentation
Systemd user unit documentation

4 Likes

The filename suffix — which you call “extension” — is part of the file’s name, and irrelevant as to whether the file can be executed or not, provided that you invoke the file by its full name.

Also, while your script may be working now, you have ignored all of the advice given to you, which means that your script will now be running with root privileges, which you said must not be the case — we don’t know, because we don’t know what’s in the script.

3 Likes

In any case, your post is no solution of any worth to others who may find this topic hoping for a solution to a similar issue.

The most likely reason for the script to magically work after removing the suffix is as @aragorn suggests; that the suffix was not a part of whichever command runs it.

Consider making an effort to address the other concerns mentioned.

The marked solution is removed.

2 Likes

Actually this is the solution because for some reason run-parts won’t run scripts that contain dots in their names.

Then, please provide evidence of that – for example, a link to wherever that information originated and a direct quote – this is an important addition for the sake of others who might experience a similar issue.

After all, this is a community where sharing is caring, rather than simply finding a vague solution to one’s own problem and promptly disappearing. You only need look at (most) other solved topics for fair examples.

A well presented summary with substance is always appreciated when a member finds a resolution to their own issue, and marks their own post as the solution.

Regards.

The script started working, but i had to remove the .sh extension from the script.

Actually this is the solution because for some reason run-parts won’t run scripts that contain dots in their names.

I can’t provide a source because I used ChatGPT, but I remember having the same problem on MX Linux, and the issue was caused by a dot in the file name. The problem is with Anacron, not Cron. On Debian and MX Linux, they are separate services, but in Manjaro, Anacron is integrated into Cronie. I prefer to use Anacron because it runs missed jobs — for example, if my PC was turned off during a scheduled job — whereas Cron does not run missed jobs.

So, your solution is based on a package that is not provided by the Manjaro repositories, though most of it’s functionality is integrated with cronie.

While there is no indication that the same issue would have presented itself using cronie, at least you have now shown enough information for others decide for themselves whether the solution has merit.

I have consolidated your last few posts which together form a more substantial response, albeit mainly anecdotal, and that post has been marked as the topic solution.

Regards.