• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

mkdir from perl script using crontab create limited permissions.

I am using perl script that remove directory and create another with the same name and the same path.

When running this script as root manually it is creating directory which is owned by root with permissins (777)when this script is running by crontab it is creating  directory which is owned by root with permissins (771)when this script is running by crontab it is creating .

 what should i do in order to run it from crontab but create with permissions(777)?  
 
0
tzahi
Asked:
tzahi
1 Solution
 
arthurdCommented:
Use chmod in your perl program:

chmod (0777,"DIRECTORY");


0
 
Brian UtterbackPrinciple Software EngineerCommented:
In the perl script, before creating the new directories,
use the umask function.

umask(0);
mkdir "directorytocreate", 0777;

0
 
tzahiAuthor Commented:
But why there is difference between  running it from crontab and from command line  as root
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now