Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
To familiarise myself with crontab, I scheduled an echo command to run and create a file in a user's home folder (report.txt) and also in a second user's account.

Example:
* * * * * echo "command" >> /home/user/report.txt
* * * * * echo "command" >> /home/otherUser/report.txt

When I go to the first account, the report is listed there. However, when I go to the second user account, the report is not listed there?

What I have tried:

I have redone the test, and this yields the same result.
Posted
Updated 16-May-21 0:52am
Comments
Richard MacCutchan 16-May-21 6:55am    
I do not think that a single crontab script can access different users' home directories.
Peter_in_2780 17-May-21 2:36am    
Provided the account has appropriate permissions, it can do anything...
cp -a * /home/victim/
will quite happily clone all my files into his space.
Variants of this have been used in various places as an el-cheapo backup
Richard MacCutchan 17-May-21 3:04am    
"Provided the account has appropriate permissions", being the key point.

1 solution

You probably don't have write permission in /home/otherUser/ , so your attempt to create the file will fail.
Check /var/log/syslog for error messages from cron.
 
Share this answer
 
v2
Comments
bob_smith_0101 17-May-21 1:24am    
@Peter_in_2780 Thank you for the guidance. I modified the permissions for that user's home directory using:
chmod 777 user

Then, I did a check using: /var/log/syslog and saw messages to confirm cron was performing this task.

Lastly, I checked the /home/user/ directory to check for the report.txt file and it was there after I changed permissions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900