Implementing cron in Yii - yii

I implemented yii-crontab as instructed in http://www.yiiframework.com/extension/yii-crontab/ . I need to call a controller action automatically by implementing the cron job. But I am getting stuck on this because I am not getting the control flow to implement my requirement. Any helps are accepting..

You can write those controller actions in a controller in the folder named commands which will be located in the app root folder, and use a shell script to execute the cron.
commands is the CLI equivalent for what the controller folder is for web. Code structuring and everything else is same. So just copy your controllerfile from controllers to commands folder. Then write a php cron or a shell script to run the command at required intervals.
More reference here
https://www.yiiframework.com/doc/guide/2.0/en/tutorial-console
Running a simple shell script as a cronjob

Related

Is there a way for me to write a script in Robot Framework that utilize's the command line functions?

I'm currently working in Linux, and I know you can use Run Process to run certain applications, but I was wondering if there's a possible way to have my script running, open command line, input, for example: "clean" which in my case processes a few functions in my bash.rc. That would be extremely helpful in my automation right now.
Well essentially, what I did was I created a separate .sh executable file. Opened my .bashrc and copied my functions / aliases into my .sh file using the gedit editor. Then from my Robot Script, I used the Run Process command (I don't have my exact code at the moment) and called my executable file.

Using Cro run for rebuilding changed client side files

cro run stops the server, recompiles, restarts the server when anything in the directory tree changes. That's great.
But when developing the client side UI, and using NPX/yarn/webpack, there is an additional step that is needed to produce the main.js file.
In the Cro tutorial this step seems to be done manually, viz., we have the line "And there we have it. npm run build, refresh, and give it a spin." Here npm run build is a command that has to be run 'manually'.
Is there a simple way, eg., using .cro.yml to force another command when changes in a sub-directory tree are detected? Eg, if the client side UI files are under path/to/cro-app/client-ui-directory and the command to be run if any files change is path/to/cro-app/client-ui/directory/yarn build
The cro-tools repo has all the file watching code associated with cro run.
So, one way would be to subclass the appropriate stuff in that repo and make a super-cro run command.
But I think the thing to do would be to set up a file watcher and trigger the rebuild in your server process. Cro files set environment variables, so you could use them to configure this behavior.

OS X GUI Cocoa app interacting with shell

Background:
We are developing an in house use only cocoa app to help us with some basic sysadmin tasks and complex website deployments. This application is basically a wrapper around many different bash shell commands. The output from these commands will sometimes need to parsed or displayed to the user.
We have played around with NSTask and are able to launch some scripts. However, this seems somewhat cumbersome (needing to set the exact path, passing in each argument separately, etc...). We can use NSTask in this way if this is actually the preferred method.
The biggest challenge so far is setting up the shell environment. We interact with many ruby gems and programs and deploy using capistrano.
The Question is:
How can we interact with the shell with an environment setup like a user? (aliases, rvm, ruby, paths)
The environment variables you'll see set in your shell in Terminal.app are pretty much confined to whatever shell you're using in the Terminal context. It's not picked up by "NSTask" automagically.
But... you do have options. Some of them are described in answers to this related question.
You can set more universal environment variables that do get picked up by NSTask via the "~/.launchd.conf" file, or you can set the shell of "NSTask" to match the one in Terminal (which means you pick up .bashrc or .profile or whatever initializes paths) via "[NSTask setLaunchPath:]" (where the launch path is your shell).
And of course you can also call "system()" from within your tools. This may also pick up the variables set in the "~/.launchd.conf" file.
More information on environment variables is available in this question.

Run a binary from .app's package contents

Can I have the binary files like .sh as part of the .app in "Package Contents".
I basically have .app which has 2 buttons start/stop which basically kicks off a process to start the server. To keep everything clean, I would like to store the start/stop shell scripts within the .app.
Can I execute those shell scripts from .app?
On the Mac, yes: use the NSTask class’s +launchedTaskWithLaunchPath:arguments: method (for example), after retrieving the path to the binaries with one of the methods on NSBundle’s—-resourcePath, -bundlePath, -pathForResource:ofType:, or whatever.
On iOS... no. NSTask isn’t available.
Yes. You'll want to look at NSTask to run your scripts or other binaries, and find the files using NSBundle's API.

How do I Include a Powershell script when publishing my VB app?

I am writing an application in VB.NET. In the app, I have a function which calls a Powershell script and places the resulting information in a text box.
I have two issues:
How to I ensure that when my app is published, the powershell script is included?
How do I reference the script in my code?
Currently, I simply give my function the full path to the script, which is in a folder on my Desktop. Obviously, this will not work once I deploy the app to other computers.
You will need to create a Setup project to get your script in place on your target system.
A first step is to change the Build Action to Content and Copy to Output Directory to Copy always.
Your Setup project can pick up the script from the VB app build result and put it in place when installing your app.
As for your question concerning the user configurable install path: The easiest way to handle this would be to add registry entry containing the selected program file path and have your app read the path from there.