Cron job failing with 'Permission denied'

The tab I’m trying to run used to run before. I don’t remember if I did any tinkering to make it work—I may have. Any help would be appreciated.

This may help as a starting point

Thanks very much for the reply, Steve. If I have to go to the academy after I’ve already endured the pain of reading man pages and googling and doing this successfully without a GUI then I might as well run the jobs manually. A copy and paste is quicker than learning to be a Cron administrator.

I have a specific problem. I’d like specific instructions on fixing it.

Fair enough. Can you post the specific text in the crontab line that is giving you difficulty

Thanks for the reply! Here is my tab -

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=isaiahsellassie
HOME=/home/isaiahsellassie/

0 2 * * * /usr/sbin/rclone sync /home/isaiahsellassie/Pictures/Senayit-Adanech Gdrive:Pictures/Senayit-Adanech > /dev/null
0 3 * * * /usr/sbin/rclone sync /home/isaiahsellassie/Documents Gdrive:Documents > /dev/null

Here is what the log says that is emailed to me -

/bin/bash: /dev/null
: Permission denied

In the meanwhile, I went to System > Administration > Users & Groups. Then I clicked on the button 'Manage Groups' and scrolled down to 'crontab'. Selecting 'crontab' I clicked on the 'Properties' button. In the box called 'Group Members' I saw my user name listed, but the check box next to it was blank. I checked the box, and then 'OK' to close the dialog. Then 'Close' to exit the whole thing.

We'll find out in a few hours if this is the permission that has been missing. If this proves to be the case it would be yet another bizarre default for a distro aimed at end users.

Thanks again!

Hi Isaiah … I recall we discussed this in the past. My system UM 16.04, I installed rclone, rclone config, named my googledrive location as ‘remote’ and in crontab -e added (make sure there is a blank line at the end of the crontab) BTW, rclone installed in /usr/bin, why is yours in /usr/sbin ?

*/5 * * * * rclone copy /home/user/Pictures/birds remote:birds

Executes every 5 mins, I get no errors. Here’s a tail of syslog … (removed some stuff)

Apr  7 18:00:01 mint CRON[3106]: (user) CMD (rclone copy /home/user/Pictures/birds remote:birds)
Apr  7 18:05:01 mint CRON[3223]: (user) CMD (rclone copy /home/user/Pictures/birds remote:birds)
Apr  7 18:10:01 mint CRON[3384]: (user) CMD (rclone copy /home/user/Pictures/birds remote:birds)

HTH

Thanks Pavlos! I did a manual install of rclone. (I did not know there was an automated install.) I followed the instructions in the text file that comes with rclone so that’s probably why it is in /usr/sbin. The location was not a problem before. In 16.04 I had crontab running nightly and sending me log emails.

I’m waiting to see if toggling my membership in the crontab group does the trick later tonight.

The error message seems to indicate bash is trying to execute /dev/null.

I can't say for sure, but I think that the issue comes from your hardcoded directory paths containing spaces (like in Document Gdrive).

I also had some trouble running cron jobs in versions of Ubuntu MATE newer than 16.04.

In my 16.04 desktop installation I was doing ‘gksudo pluma /etc/crontab’, and then editing the file directly. It was working for me fine in 16.04 and still does.
Then I installed my Nextcloud server in Ubuntu MATE 17.10 and I found I was unable to get rsync working by crontab to perform nightly backups.

I wasn’t until I went and read the Ubuntu Community Docs Cron Howto that I discovered that I really should have been doing ‘sudo crontab -e’ instead.

As soon as I started following the advice in the above linked how-to I had no more problems. I am guessing something has been changed since 16.04 and we can’t do things the old fashioned way anymore. I’m not sure if anybody else has the same problem I had or not, but has been my experience, I hope it might be helpful to somebody.

Thanks for the reply, Ouroumov. The syntax in my tab is unchanged. No, there are no spaces in the directory paths.

Thanks for the reply, Herman. I am not doing anything that needs su level permission. I spent a lot of time figuring all this out when I first set up the crontab. I do not have time to spend on researching and tinkering all over again. I would rather run it manually if I can’t get a quick fix. I’ll set up a reminder in my iPhone.

Checking the box for my user name in crontab group did not solve the problem. Although I have not rebooted since, so maybe after a reboot it will work.

I tried it on a fresh install 18.04b2 …
install curl … sudo apt install curl
to install rclone … curl https://rclone.org/install.sh | sudo bash
to config rclone … rclone config (selected google-drive, call it remote)
to run … rclone sync Documents/ remote:beta
no need to change groups/reboot/anything …

1 Like

Thanks Pavlos. I already have curl and rclone installed. I already know how to configure and use rclone. My problem is crontab failure.

ok, get rid of the env variables, your crontab -l should look like:

 # m h  dom mon dow   command

 */5 * * * * rclone sync /home/user/Documents remote:beta

Thanks again, Pavlos. I arrived at the current crontab after considerable research, and trial and error. I started with simple, and added things as necessary to get it to work. It worked fine before, so I’m pretty sure there is nothing wrong with the tab itself. The error is ‘Permission denied’. There is nothing I am doing that is contradictory to the Ubuntu How-to page referenced above. (There is neither cron.allow nor cron.deny in the /etc directory, for example.)

When you run the command from a terminal
rclone sync /home/isaiahsellassie/Pictures/Senayit-Adanech Gdrive:Pictures/Senayit-Adanech
do you get an error? (I removed the /dev/null redirection)

can you post the output of ls -l /dev/null it should be:
crw-rw-rw- 1 root root 1, 3 Apr 7 08:09 /dev/null

No, there is no error when running rclone manually. There is no /dev/null in the command.

The output is:
crw-rw-rw- 1 root root 1, 3 Apr 7 15:06 /dev/null

I googled and came up with this, so I did it
sudo chown username /var/spool/cron/crontabs/username
But, no luck. Same error as before.