Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory (spawn /tmp/cronicle-script-temp-jlre950l608.sh ENOENT) #707

Open
coffseducation opened this issue Jan 15, 2024 · 7 comments

Comments

@coffseducation
Copy link

Summary

Cron job results in error:
No such file or directory (spawn /tmp/cronicle-script-temp-jlre950l608.sh ENOENT)

Steps to reproduce the problem

1.Set up cron job
2. Paste in bash script
3. Save
4. Run
5. error

Your Setup

Operating system and version?

Ubuntu 22.04

Node.js version?

Cronicle software version?

Version 0.9.39

Are you using a multi-server setup, or just a single server?

single

Are you using the filesystem as back-end storage, or S3/Couchbase?

Can you reproduce the crash consistently?

Yes.
Script run fine when trigged manually

#!/bin/bash

DB Container Backup Script Template

---

This backup script can be used to automatically backup databases in docker containers.

It currently supports mariadb, mysql and bitwardenrs containers.

DAYS=2
BACKUPDIR=/home/barkingb/backups

backup all mysql/mariadb containers

CONTAINER=$(docker ps --format '{{.Names}}:{{.Image}}' | grep 'mysql|mariadb' | cut -d":" -f1)

echo $CONTAINER

if [ ! -d $BACKUPDIR ]; then
mkdir -p $BACKUPDIR
fi

for i in $CONTAINER; do
MYSQL_DATABASE=$(docker exec $i env | grep MYSQL_DATABASE |cut -d"=" -f2-)
MYSQL_PWD=$(docker exec $i env | grep MYSQL_ROOT_PASSWORD |cut -d"=" -f2-)

docker exec -e MYSQL_DATABASE=$MYSQL_DATABASE -e MYSQL_PWD=$MYSQL_PWD \
    $i /usr/bin/mysqldump -u root $MYSQL_DATABASE \
    | gzip > $BACKUPDIR/$i-$MYSQL_DATABASE-$(date +"%Y%m%d%H%M").sql.gz

OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz |wc -l)
if [ $OLD_BACKUPS -gt $DAYS ]; then
    find $BACKUPDIR -name "$i*.gz" -daystart -mtime +$DAYS -delete
fi

done

echo "$TIMESTAMP Backup for Databases completed"

Log Excerpts

Job ID: jlre950l608

Event Title: Database-backup

Hostname: main

Date/Time: 2024/01/15 03:34:06 (GMT+2)

Job failed with error: Script failed: No such file or directory (spawn /tmp/cronicle-script-temp-jlre950l608.sh ENOENT)

2 retries remain

Job ID: jlre950l608

Event Title: Database-backup

Hostname: main

Date/Time: 2024/01/15 03:34:06 (GMT+2)

Job failed with error: Script failed: No such file or directory (spawn /tmp/cronicle-script-temp-jlre950l608.sh ENOENT)

1 retries remain

Job ID: jlre950l608

Event Title: Database-backup

Hostname: main

Date/Time: 2024/01/15 03:34:06 (GMT+2)

Job failed at 2024/01/15 03:34:06 (GMT+2).

Error: Script failed: No such file or directory (spawn /tmp/cronicle-script-temp-jlre950l608.sh ENOENT)

End of log.

@jhuckaby
Copy link
Owner

The problem is likely your Linux distro doesn't allow executable scripts in the /tmp directory. I think "hardened" Linux flavors have this restriction.

See this issue: #133

@coffseducation
Copy link
Author

Ok, thanks.

I added "TMPDIR" to environment variables with /home/barkingb/tmp
but got
Error: ENOENT: no such file or directory, open '/home/barkingb/tmp/cronicle-script-temp-jlreb3sjr04.sh'

I suppose I need to un-harden /tmp

Cheers.

@jhuckaby
Copy link
Owner

Does /home/barkingb/tmp exist? You'll have to pre-create it, and chmod it to 777, like /tmp is.

But yeah, unhardening /tmp would probably work best.

Good luck!

@coffseducation
Copy link
Author

I had created the tmp but had not chmod 777 it.
It still does not work.
Error: ENOENT: no such file or directory, open '/home/barkingb/tmp/cronicle-script-temp-jlree04cu03.sh'

I cannot find any info on how to unharden /tmp so I think I will look into doing a manual entry in crontab.

Thanks so much for your help!

@jhuckaby
Copy link
Owner

Oh, how weird. I don't know anything about hardened Linux, so forgive my lack of knowledge here, but I wonder if it has something to do with traversing into your home directory. Maybe try something like /opt/cronicle/tmp ?

@coffseducation
Copy link
Author

Error: ENOENT: no such file or directory, open '/opt/cronicle/tmp/cronicle-script-temp-jlreeulbo01.sh'

@jhuckaby
Copy link
Owner

Wow, okay, I am at a loss. I have no idea how to solve this one. I'll re-open this issue, so others can see it.

@jhuckaby jhuckaby reopened this Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants