Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to make cron jobs work, and several sources online said to use the command crontab -e to view the cron table. However, when I try to do so, the terminal hangs up.
How do I a) prevent this from happening, and b) unlock the terminal when it does?
@frankbell - no, the cursor disappears in the Terminal window and the terminal is unresponsive.
@serOlmy - I don't have access to the server right now, but I will check your suggestion in the morning.
a look at tail /var/log/cron shows that the script has been called, but the output is not seen in testlog.log. crontest.php has permission 744 and testlog has permission 644.
a look at tail /var/log/cron shows that the script has been called, but the output is not seen in testlog.log. crontest.php has permission 744 and testlog has permission 644.
What have I missed?
Errors are probably ending up in a file called "%1". I think you want "2>&1" not "2>%1".
Also, if you just want to view the crontab use "crontab -l" instead of "crontab -e".
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by newheart42108
I am trying to make cron jobs work, and several sources online said to use the command crontab -e to view the cron table. However, when I try to do so, the terminal hangs up.
I'm wondering if this isn't an environment setting problem.
Anyway... you can simply use "crontab -l" to view a cron table.
Another option: If "crontab -e" is acting, uh, "wonky", keep your crontab under $HOME (say, "my.crontab"), edit it there, and "submit" it using "crontab $HOME/my.crontab".
Thanks, @evo2. That at least got me error messages in my log file.
Cleaning up a couple more php errors got me nearly to what I wanted:
I was under the impression that adding the shebang in the php file would allow php to be processed. This is apparently not the case. Adding the /usr/bin/php in the cron command cleared that up.
There appears to be no time zone "America/Chicago" for US CST in php. I'll have to research what that should be.
The last issue is that I thought that cron logs automatically appended new lines to the log file defined. Is there a command I have to add to make that happen? I am seeing the new log line overwrite what's already in the file.
#!/usr/bin/php
<?php
date_default_timezone_set('America/New_York');
echo "This is the output on ".date("M j, ").'at '.date("G:i:s")." EDT\n";
date_default_timezone_set('America/Chicago');
echo "This is the output on ".date("M j, ").'at '.date("G:i:s")." CDT\n";
date_default_timezone_set('America/Denver');
echo "This is the output on ".date("M j, ").'at '.date("G:i:s")." MDT\n";
date_default_timezone_set('America/Los_Angeles');
echo "This is the output on ".date("M j, ").'at '.date("G:i:s")." PDT";
?>
This is the output on Apr 12, at 22:45:14 EDT
This is the output on Apr 12, at 21:45:14 CDT
This is the output on Apr 12, at 20:45:14 MDT
This is the output on Apr 12, at 19:45:14 PDT
Using PHP 7.4.16 works for me. By the way, /usr/bin/php is the command line interpreter which is different then the apache php parser module used for php web pages. When using the shebang, if the php script is executable it should be executable from a cron script as long as the other permissions are set correctly. With redirection, using a single > overwrites the file, using >> appends.
Thanks to all. I hope this helps someone down the road.
@michaelk I originally had 'America/Chicago' but was shown an error. I just inserted it again and all was well. Now that I am over the frustration of getting NOTHING, I will be able to make changes and examine the results.
Oh, and BTW, changing the > to >> before the output path solved the overwrite vs append issue
Last edited by newheart42108; 04-12-2021 at 10:16 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.