Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a server for which I have created a cron job "sendalerts" to users. Mind you this "sendalerts.php" should be runnable from two methods (via browser and also via a cron job)

So cron's job is to execute a php file which then sends the alerts out, something like this:

01 01 * * * /usr/bin/php -f /var/www/vhosts/xxxxx.com/xxx/sendalerts.php

But it keeps failing with the log message:

Could not open input file: /var/www/vhosts/xxxxx.com/xxx/sendalerts.php

So I checked the file group and owner of "sendalerts.php" and realized it was "anothergroup" (since it was created through Plesk filemanager) for which "root" is not a member. I then deleted and recreated "sendalerts.php" from SSH with root. But this would not grant me access to running the same file in browser as I would sometimes want to (manually send the alerts).

Yet I get the same log error when cron tries to execute (Could not open input file: /var/www/vhosts/xxxxx.com/xxx/sendalerts.php)

Currently my possible solution would be:

to recreate the same file using Plesk filemanager and then add "root" user to the "anothergroup" group . But for this My QUESTION is : would that be a safe and secure thing to do? considering now the group "anothergroup" may have "root" user permissions (if im not wrong in my understanding)

Scout for other better solutions, Please if anyone has a better solution to this please suggest/advise me on this. Thanks,

boxmluh

share|improve this question

closed as off-topic by Falcon Momot, dawud, Ward, mdpc, Tom O'Connor Aug 19 '13 at 21:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Falcon Momot, dawud, Ward, mdpc, Tom O'Connor
If this question can be reworded to fit the rules in the help center, please edit the question.

    
how do you configure cron? which file? –  GioMac Aug 17 '13 at 12:29

2 Answers 2

Adding root to said groups won't help as root should be able to access "anothergroup" GID owned files already.

Check the audit logs (some times located under /var/log/audit/) for any error message. For example SELinux or Apparmor may be preventing root from reaching into your directory through cron.

Other possible explanations may be that the /var/www/vhosts/xxxxx.com/xxx/ dir is located on an NFS share or the like, and root gets squashed? In that case I suggest you create a user who is a member of the "anothergroup" group and see if that helps.

share|improve this answer

Put the command in the crontab of a user who is member of "anothergroup".

However, I am wondering, usually root can access anything, why not here?

In any case, making root member of "anothergroup" won't hurt either. There's nothing on a system that is "run as the group". Stuff is only run as a user which is a member of group(s).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.