0

I have a task (script) that I added via crontab -e (Ubuntu 20.04). The task uses gio to copy a file in /tmp (that was created a line before in the script) to Google Drive. Running the gio command in a shell works fine, but it fails in the task. The failure is

gio: file:///tmp/wiki.tar.bz2: Operation not supported

Why it it working under the shell but not the task? The task runs under my user (as I can see using whoami and id in the script and also the file that is created is owned by me)

The script is

#! /bin/bash

cd ~/
tar jcvf /tmp/wiki.tar.bz2 Wiki
gio copy /tmp/wiki.tar.bz2 google-drive://ittay@company.com/
larsks
  • 41,276
  • 13
  • 117
  • 170
IttayD
  • 1,037
  • 4
  • 11
  • 14
  • 1
    What does the complete cron task look like? – larsks Sep 04 '22 at 12:36
  • I suggest using a shell script for cronjobs so you can add any tests or environment variables. I do suspect that your issue is that you have selinux and cron jobs running under a different security context. Someone had a similar issue here: Seehttps://unix.stackexchange.com/questions/671170/permission-denied-inside-a-cron-script – toppk Sep 04 '22 at 21:43
  • @larsks, added the entire job. Not sure if it adds much information. As mentioned, the last line works if pasted in a shell – IttayD Sep 05 '22 at 04:22
  • @toppk, it is indeed a shell script that I run. – IttayD Sep 05 '22 at 04:22
  • @toppk, when I run `id -Z` I get `id: --context (-Z) works only on an SELinux-enabled kernel`. So I assume selinux is not involved here. – IttayD Sep 05 '22 at 04:25
  • cron runs under a very limited environment set. you can simulate this by running "env - /path/to/scrip". See if it works under that circumstance. I suspect that since it is gnome software it is missing some of the XDG_* variables. – toppk Sep 05 '22 at 04:34
  • @toppk, that is it. you can write as an answer. – IttayD Sep 05 '22 at 06:01

0 Answers0