CE - seaf-gc.sh non running in crontab

server

#1

Hi there, I’ve found a strange issue, maybe somebody has solved it.

I need to run seaf-gc.sh often, because my library sync a huge file that keeps evolving.

Now if I run seaf-gc.sh either manually with user seafile and from the script (posted below) with user root it runs great and frees the space I need.
But if I run it in crontab (root crontab) it doesn’t run.

Here is the cronjob I run:
0 1 * * * /script/seafile_cleanup.sh

And the seafile_cleanup.sh script:

#!/bin/bash
##########

echo "Registering space BEFORE script"
echo "BEFORE" >> /script/seafile_cleanup.sh.log
date >> /script/seafile_cleanup.sh.log
df -h /dev/vda >> /script/seafile_cleanup.sh.log

service seafile-server stop
sleep 20

su seafile -c "/home/seafile/seafile-server-latest/seaf-gc.sh"
sleep 10

service seafile-server start
echo "Registering space AFTER script..."
echo "AFTER" >> /script/seafile_cleanup.sh.log
date >> /script/seafile_cleanup.sh.log
df -h /dev/vda >> /script/seafile_cleanup.sh.log

echo "" >> /script/seafile_cleanup.sh.log
echo "" >> /script/seafile_cleanup.sh.log

Any help please?


#2

Chmod x+

?


#3

The script is run by root user which has permission to execute.

 ll /script/seafile_cleanup.sh
-rwxr--r-- 1 root root 1067 Apr 15 09:37 /script/seafile_cleanup.sh*

#4

Looks fine to me.

The folder script is in root? (/scripts)

Try to execute the script with ... ** bash /scripts/seaf...


#5

I’ll try it.


#6

Nope, it’s not working. Maybe it has to deal with env variables that may differ when used in cron, I’ll investigate


#7

Ok the problem where environment variables which are different from system and cron. I’ll post the solution in case it could help others.

You have to tell cron to use correct variables by putting them in the script directly or in crontab itself (and it will work for all cronjobs).