how to run a python script everyday by using at command? - at-job

I would like to run a python program everyday.
I figured out how to do at specific time.
sudo echo "python ./test.py" | at 6:00
However I don't know how to run this script everyday.
I tried this:
sudo echo "python ./test.py" | at 6:00 everyday
Then it didn't warn me anything, and it ran once, but when I checked atq afterwards, there is nothing there.
so it means it will not be run everyday.
How can I run a python script everyday ?
( I am using mac os x. )
Thank you.

Use a cron to run your script.
Most People are using cronix for cron jobs on the mac, I believe...
You can get it here:
https://code.google.com/p/cronnix/

Related

Schedule a Perl script run in Ubuntu. Not looking at cron

I've got this Perl script on Ubuntu that I need to run at a particular time in the future. I don't need it to run at that time more than once or basically what I'm trying to say is that it does not need a cron.
I need to schedule a run at a future time to run once and that's it. Any idea how to go about it? I've googled a bit but every time the concept of cron comes up so not really helpful.
I do have some code. The user clicks on a button (say "Schedule") on the GUI and a process starts in the background which schedules the run after (say) N hours.
I'm ready with the GUI and the connection to the backend Perl script. The N hours is predetermined. But I don't know how to code the scheduling concept in the Perl script.
One way is that your Perl scripting will just sleep(seconds) and then execute the action. In case you don't want to have this you need to tell some other service that it should invoke a program at a specific time. In UNIX this is usually done with the at command.
Use the at command:
echo 'perl foo.pl' | at now + 3 hours

run and stop perl script from cron job - cpanel

My path to the perl script is
public_html/Staging/ff/sendmail.pl
The command to run the perl script in cron job cpanel is
cd /public_html/Staging/ff; perl sendmail.pl >/dev/null
is set to every 1 min, which is not working. What could be the issue? And how to stop the same process
While my answer is extremely late to the party;
As of CPanel 102.. (and for various releases before this) The reason the cronjob does not run is that CPanel crons do not "queue" commands; you can only run one command at a time per cron.
Therefore:
perl /public_html/Staging/ff/sendmail.pl >/dev/null
will work as your cron command, using absolute pathing and removing the need to change directory.

Use cygwin to run a batch file and email results

I am new to using cygwin and don't really understand how the scripting of it works. Currently I am running it on Windows 7 and using task scheduler to do this inefficiently.
What I want to do is to run a .bat file already made that runs tests in the cmd line and than take the results of that test and email that people.
Some side notes:
1. It doesn't HAVE to be a batch file, from my reading I think maybe a .sh would be easier to run with bash. Being able to run it on CentOS would be even better, that way others can run if I leave.
2. This needs to run daily. I would like to run the batch file at around 10 am and give it an hour till the emailed results are sent, unless you can trigger the email when the .bat is done.
3. Every time I run this .bat file it saves the results to a .htm file and overwrites it every time the .bat is run.
Thank you
That could be in the crontab for a a centOS server (/etc/crontab)
0 10 * * * user cd /path/ && /bin/bash file.sh >> result_file
Is that what you needed ? Also, you can install Cron as a windows service with cygrunsrv

perl based cron job won't write to mounted cifs/windows share ONLY after long inactivity

I'm not sure how to title that more succinctly and still have it be meaningful.
(Note that this works fine when run mid-day, via cron or manually, so I "know" the script itself is sound.)
I have a cron job (ubuntu 13.04.)
It runs as my user (not root.)
The job itself runs at 6:00 in the morning. It's the first 'business level' job that runs all day.
1 6 * * 1-5 /home/me/bin/run_perl_job
run_perl_job is just:
#!/bin/bash
cd /home/me/bin
./script.pl
The script copies a file to "/mnt/shared_drive/outputfile.xls"
The mount point is defined in fstab as:
//fileserver/share /mnt/shared_drive cifs user=domain/me%password,iocharset=utf8,gid=1000,uid=1000,sec=ntlm,file_mode=0777,dir_mode=0777 0 0
Now. Given that:
When I run the script in a normal shell, it works fine.
When I look at the mount point first thing in the morning (via a normal terminal) it shows up (and is writeable) without event.
When I copy the crontab line and set it to run in a couple minutes, to see the symptom, it works fine (creates the file quite happily.)
The ONLY time this fails is if it's running in its normal time slot (6:01). The rest of the script functions ( the file itself has to be pulled down via sftp, etc.) So I know it's not dying.
It's driving me batty because the test cycle is 24 hours.
I just added the following couple lines to the beginning of the 'run_perl_job' script, hoping it exposes something tomorrow:
cd /mnt/shared_drive
ls -lrt >>home/me/bin/process.log
But I'm stumped. "It's almost as though" the mount point had gotten stale overnight and is waiting for some kind of access attempt before remounting. I'd run "mount -a" at the top of the 'run_perl_job' script if I could reasonably do it. But given that it's got to be sudo'ed, that doesn't seem reasonable to me.
Thoughts? I'm running out of ideas and this test cycle is awful.
how about putting a
umount -f -v /mnt/shared_drive
mount -v -a
into a root cron job just before your script runs. That way you don't need to sudo in your script and have the password in plain sight. -v might give you a hint on what is happening to make it stale

How to invoke an opened Exceed window to run a Perl script using a Schedule Task

TASK TO BE ACCOMPLISHED:
To schedule a perl script which is executed on a specific time / day in a week
THINGS I HAVE DONE:
In a schedule Tasks, I have created a new Task by which the Task will call a batch file with below contents
cd "DRIVE\FOLDER\Hummingbird\Connectivity\14.00\Exceed\"
ABCD.xs
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
THINGS NOT WORKING FOR ME / CAUSING THE ISSUE:
Wen I run the scheduler, the prompt opens up the ABCD.xs exceed file window seperately file but the below commands are executed in the command pronpt itself
EXPECTED OUTPUT:
I want the commands
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
to be executed in the exceed window
Any kind of solution wud be great
Thanks in advance.
Haresh
Sounds like you need to start getting into either SendKey stuff (Win32 packages) or else look into writing Exceed/Hummingbird scripts and just executing those.
Some other things to look into... does the remote server have a telnet or ssh server running? Or are there other methods of executing code on the remote server?
For example, my work's mainframe is accessed via a Hummingbird terminal emulator, but I can also telnet to the mainframe and execute commands as well as FTP batch job directly into the JES spool. So when I execute things on the mainframe by way of my PC (Perl scripts, etc.), I don't even fool with Hummingbird.
Good luck...