Simple for those who know.

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Simple for those who know.
# 1  
Old 02-07-2017
Simple for those who know.

Hi,
In Php I can use exec() to access the shell from my .php web page. Tested and it works.

So, I need to create a cron job that visits my URL at the time contained in my $time php variable. That's it, just one visit to the specific URL.

Once the visit takes place, delete the cron job using exec(whatever command is needed to delete the cron job).

I know nothing about Linux commands to create cron jobs. I do know that I can use exec( Linux command to create said cron job and or delete cron job) in php.

Can someone please fill in the () to accomplish this?

It's a php web page that will run for 24 hours about three times a month. No consistency to the times or monthly pattern. Thus the need for self contained create/delete cron job.

Site is very low traffic and the cron visit is needed to trigger an email function at the specified time.

Thanks very much for any assistance!
# 2  
Old 02-08-2017
The normal way to add and remove cron jobs for a user is by using crontab -e which, by default, uses vi (which is an interactive editor). You could use a command like:
Code:
EDITOR=ed crontab -e <<-EOF
place editing command(s) here
EOF

but with no indication of what the cron job to be deleted looks like and what other cron jobs this user might also have in their crontab job list, it is impossible to suggested what editing command(s) might be needed to solve your specific problem.
# 3  
Old 02-08-2017
Thanks Don.
There won't be any other cron jobs and I am the only user.
# 4  
Old 02-08-2017
In that case, the editing commands:
Code:
1d
w
q

should be sufficient.
# 5  
Old 02-08-2017
For a one-off execution of some command, did you consider the at command?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A Simple Clock, Well Maybe Not That Simple...

The attachment says it all really... It is a DEMO at a glance digital readout using the "date" command to make it useful... For a Mocbook Pro 13", OSX 10.7.5, but may well work on Linux variants too. Enjoy... #!/bin/bash # # Clock.sh # A bash DEMO to create a 6 x 7 character set... (4 Replies)
Discussion started by: wisecracker
4 Replies

2. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

3. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

4. Shell Programming and Scripting

Simple to you not simple to me pattern matchin help

hey all, im new and my first question is: say i have a word "blahblah" how do i get and replace the last letter of the word with say k, so replace the h with a k. However you cant just replace the h it has to change the LAST LETTER of the word. Cheers In advance. :b: (0 Replies)
Discussion started by: aleks001
0 Replies

5. Programming

Simple C question... Hopefully it's simple

Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple... (6 Replies)
Discussion started by: Xeed
6 Replies

6. UNIX for Advanced & Expert Users

simple one

echo echo ((zz=$ee+$ff+$aa)) echo $zz <==Problem==> ee= 12.5 ff = 20.6 aa = 10.5 The ouput of zz should be 43.6 BUT i am getting 42. So it means anything after the comma is not counted. Please help. (2 Replies)
Discussion started by: kekanap
2 Replies

7. Shell Programming and Scripting

Just something simple

Hi, new to the forums and just need a little help, I have a sript to write and as far as I can see it should work fine but it refuses to run properly, it has issues with the end of a line but I see no issue, would anyone assist please, I just someone to seconed check I have not overlooked something... (5 Replies)
Discussion started by: Dim-Wit
5 Replies

8. Shell Programming and Scripting

Simple if

Hi, I have a variable (x) that holds a file name - I need to write this: if x matches the patern *ABC* or the pattern DEF*T then action A else action B fi how to do that? Also, how can i change the or test to AND test? Thanks. (2 Replies)
Discussion started by: GNMIKE
2 Replies

9. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies
Login or Register to Ask a Question