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

[Question]: how to change the home directory while creating cronjob?? If my file was in different directory then cron runs on home directory?? #132

Closed
vishnumur777 opened this issue Jan 1, 2023 · 2 comments

Comments

@vishnumur777
Copy link

Log File

From [email protected] Sun Jan 1 23:13:01 2023
Return-Path: [email protected]
X-Original-To: root
Delivered-To: [email protected]
Received: by localhost.localdomain (Postfix, from userid 0)
id 94FCB262A32; Sun, 1 Jan 2023 23:13:01 +0530 (IST)
From: "(Cron Daemon)" [email protected]
To: [email protected]
Subject: Cron root@VISHNULAP export . /root/.profile; /root/bashPractice/insert.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=c220>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus>
X-Cron-Env: <XDG_SESSION_TYPE=unspecified>
X-Cron-Env: <XDG_SESSION_CLASS=background>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: [email protected]
Date: Sun, 1 Jan 2023 23:13:01 +0530 (IST)

/root/bashPractice/insert.sh: line 3: ./content.sh: No such file or directory
cat: '*.n': No such file or directory

@t8m
Copy link
Member

t8m commented Jan 2, 2023

You cannot change the directory where the command from crontab is run at. But that's no problem, you can do that in the command itself.

* * * * * cd /whatever/directory ; yourscript

@vishnumur777
Copy link
Author

Thank you @t8m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants