Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  98] [ 0]  / answers: 1 / hits: 519345  / 1 Year ago, wed, january 25, 2023, 3:25:11

I had set a cron job:



20 * * * * /usr/bin/sh /home/lucky/myfile.sh


The main problem is that at the schedule time, there is an error:
"mail have sent to /var/spool/mail/lucky".



The contents of myfile.sh is:



mkdir jh
cd jh

More From » cron

 Answers
5

This is not ok for a script which is set as a cron job:



mkdir jh
cd jh


You should give the full path where jh directory must to be created. Also, in this path you should have permission to create new files/directories.



For example, your script should look like:



#!/bin/sh

mkdir /home/lucky/jh
cd /home/lucky/jh


Also /usr/bin/sh is not the right path for sh. The right path is /bin/sh. You can check this with whereis sh command. And even so, your cron job should look like:



20 * * * * /home/lucky/myfile.sh


Don't forget to make the script executable:



chmod +x /home/lucky/myfile.sh

[#29244] Friday, January 27, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellter

Total Points: 311
Total Questions: 111
Total Answers: 117

Location: Lithuania
Member since Thu, Jul 14, 2022
2 Years ago
;