If you set up crontab and run cron on Amazon Linux, the file created will have 644 permissions.I'd like to create 664 files, which Linux settings should I change?I can do it by specifying permission and umask in the php file, but I would like to change it to Linux settings.
If you change the umask of the cron running user to 002, the file created after cron running will be permission 644.
I don't understand why the file created by running the php file through cron does not become the umask002 that I set first.
crontab
2701**/usr/bin/php/aaa/index.php
index.php
<?php
$file="/data/bbb.txt";
$string = "Hello, PHP";
file_put_contents($file,$string);
When running cron, the login shell does not work, so the contents of the profile of the cron running user are not read.I think you can explicitly write the execution umask and the necessary environment variables on the crontab, so please try it.
2701***umask0002;/usr/bin/php/aaa/index.php
Alternatively, setting the default umask when running cron on pam might be effective.
File /etc/pam.d/crond
session optional pam_umask.so umask=0002
© 2024 OneMinuteCode. All rights reserved.