Skip to main content
Bumped by Community user

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows :


STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 -print -delete >> /home/jboss/.log_$STAMP 2>&1

The ls -ld /local/java_apps command gives:

STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f drwxrwxr-iname '*.pdf'x+ -mtime3 +180root -root 
print4096 Oct -delete10 >>2017 /homelocal/jbossjava_apps/<name>.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this:

0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error:

find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows :

STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - 
print  -delete >> /home/jboss/<name>.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this:

0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error:

find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows :


STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 -print -delete >> /home/jboss/.log_$STAMP 2>&1

The ls -ld /local/java_apps command gives:

drwxrwxr-x+ 3 root root 4096 Oct 10 2017 /local/java_apps/

The crontab looks like this:

0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error:

find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps//local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss/home/jboss The code is as follows : STAMP=$(date +"%m%d%Y%H%M%S") sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - print -delete >> /home/jboss/.log_$STAMP 2>&1

STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - 
print  -delete >> /home/jboss/<name>.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this - 0 1 * * 4 /etc/cron.weekly/servercleanup.sh:

0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error : find: failed to restore initial working directory: Permission denied

find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows : STAMP=$(date +"%m%d%Y%H%M%S") sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - print -delete >> /home/jboss/.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this - 0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error : find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows :

STAMP=$(date +"%m%d%Y%H%M%S")
sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - 
print  -delete >> /home/jboss/<name>.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this:

0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error:

find: failed to restore initial working directory: Permission denied
Source Link
Yash Gandhi
  • 81
  • 1
  • 1
  • 3

find: failed to restore initial working directory: Permission denied

I am trying to find some files on a path /local/java_apps/ and then delete them using a shell script and generate a log file in the /home/jboss The code is as follows : STAMP=$(date +"%m%d%Y%H%M%S") sudo -u jboss find /local/java_apps/ -type f -iname '*.pdf' -mtime +180 - print -delete >> /home/jboss/.log_$STAMP 2>&1

Here root has 777 permissions to the path where the find is used. The crontab looks like this - 0 1 * * 4 /etc/cron.weekly/servercleanup.sh

When the script is run by the crontab it gives the following error : find: failed to restore initial working directory: Permission denied