mac osx cant find cronjob which opens safari every few seconds - macos

I´ve installed a cronjob under mac osx which opens/curl an URL. Everything works fine but now I deleted all cronjobs by
crontab -r
and I deleted all lines in the crontab and
crontab -l
does not deliver any entry. The problem is that safari still opens every few seconds. Its also blocks my reboot command. I have to shut it down manually then I can restart my mac. When I get my login screen where I can click my User-Button the mac does a short "flash". So the screen gets white for one short moment. Looks like if you do an screenshot on an Iphone. Safari opens itself on startup (There is no entry in the startupitem list) to execute the Url. Somehow it feels as if there is a cronjob running in the backround but I cannot find it! Thanks.

Try running this script to see if you can spot the curl process being run, then you can find its Parent Process Id (PPID) in column 3, and then see the PID of the calling process. That will tell you how it is getting launched - or by whom, at least.
while :; do ps -aef | egrep "UID|curl" ; sleep 1; done

Ok, I found a solution. I had a .plist in /Library/LaunchAgents calling my URL. I deleted it, remove from trash and restared computer. No it´s gone. Yes.

Related

shell command fails when running from crontab

[Edit: the original title of this question was "Applescript running from crontab not accessing network?" but having found that the problem is about PATHs--not networking, or for that matter Applescript--I have tried to make it more searchable.]
I have a script which I would like to run at 9pm every night that will give me an alert if the Raspberry Pi in my basement is not responding. The script works fine, and tells me my device is up when I run it by hand:
osascript /users/nat/Code/applescript/ping-pi.scpt
It also runs from my crontab, but it tells me my device is down... which it isn't.
Here is the crontab line that worked a few minutes ago (for testing, not for 9pm):
14 15 * * * osascript /users/nat/Code/applescript/ping-pi.scpt
Here is the script:
--based on https://discussions.apple.com/thread/3833490
try
set ping to (do shell script "ping -c 2 <ddns site name here>")
display dialog "<ddns site name here> is up and running!" with icon note buttons {"OK"} default button 1
on error
-- if we get here, the ping failed
display dialog "<ddns site name here> is not responding" with icon caution buttons {"OK"} default button 1
end try
The only thing I can think of is that maybe I need to run it as root, but I don't know why that would be.
I can probably get rid of the "set ping to," but I'm just adapting code I found.
It turned out that this was not a network-access issue at all, but a PATH issue. I learned in this post that the default path for cron jobs includes just /bin and /usr/bin. which ping told me that I needed /sbin/ping, and when I edited the script accordingly, it worked.
I would imagine that this would cause many cron tasks to fail, so I'm a little surprised that it didn't come to my attention sooner.
As I mentioned above, there is no problem putting up a dialog from a cron job, and I will try removing the extra permissions I added, because I'm guessing I don't actually need any special network permissions.

Run my Mac command "chsh -s /usr/local/bin/false" and can't log in to my account again

I really messed up!
Since I ran my Mac with the command below
chsh -s /usr/local/bin/false
Several minutes later, I noticed my Mac logged out by itself.
So, I tried to log back in by clicking 'change user'
But I can't see my administer account there.
I guess 'false' is not a loggin-able shell, that's why my account is hidden.
I'm trying to change my shell with Terminal.app on recovery mode or single-user-mode (but both are read-only).
So right now, I want to know if there's any solutions that might be able to fix this problem.

mac terminal login costs too much time

Every time I open a new terminal it costs about 3-5 seconds to login , plz see the screenshot.
Terminal seems to save every command to ASL (Apple System Log) log files and it can become cumbersome. Many reports that deleting ASL log files speed up the Terminal. Try:
sudo rm /private/var/log/asl/*.asl
and relaunch Terminal.

How to share the screen output of a running process?

I have a program that will run for a long time , This program edit and run in remote server .I use
the computer in office to remote connect the server and run it . The progress shows on the computer screen of the computer in my office ...
I want to see the output in my home , How can I capture the output which is on the screen of computer in office and see the result at home?
I think about writing the output to a file , but I need to close the file . So I should open file then write output , close .. open again?
thanks
I don't know the proper tag should use , but the program is written in perl .....
you can tee it
your_program.pl | tee logfile.txt
and see the lastest result in logfile.txt at home with
tail -f logfile.txt
Why not just redirect to a log file and tail it (or load it in an editor etc.) ?
$ myprog.pl >/tmp/logfile 2>&1
The above redirects your output to a log file (/tmp/logfile - you may wish to choose a better location since /tmp is temporary and can be trashed during a reboot) and redirects stdout/stderr to the same place. Note that this captures the output of your program and you don't need to modify your script.
An alternative is to run your program within screen
Perhaps one of the most useful features is that you can re-connect to
your sessions after you log out, move to another computer, or get
disconnected, and continue working as if nothing happened. All your
edit sessions, shell windows, etc. will be there just as you left
them.
Personally, I use screen for this sort of thing.
Connect to the server
Enter the command screen. It displays a nice message stating the version of screen and that it's under the GPL.
Run the actual command.
At any time, hit ctrl-A, D to disconnect from the screen session. You'll see a message along the lines of [detached from pid.tty.server]. Log out from the server normally.
Connect to the server again and enter the command screen -x to reconnect to your session.

Mac OS - add app to autostart with launchctl

I can start application with launchctl like this: launchctl submit -l ProgramName -- open -g -b com.company.ProgramName and it works great! I can kill app, and it'll re-run again even if it crashes.
But when i logout or reboot Mac, my process is no longer run. Or, in some cases, it runs not with ProgramName (whitch is my application name), but with name of executable file in ProgramName.app/Contents/MacOS/program_name
Such situation with plist files. I run command launchctl -w /Users/my_username/Library/LaunchAgents and process works fine! But after restart i can't see it.
I prefer first method to load processes, any suggestions why process doesn't autoload after reboot?
I believe you need to set "RunAtLoad" to "true" for it to start your application when user logs in.
But there is no way to set RunAtLoad from command-line when using "submit". At least not in the version of launchctl.c that I checked online.
It looks like you have to create a .plist file with "load", instead of using "submit".
What is more annoying is that launchctl's "load", can not take stdin as input to .plist filename, either with no-argument, or name "-". Shame, perhaps the developers of launchctl are not from Unix background. This means you are forced to litter your short-lived file somewhere on the file-system, at least until you have it loaded.

Resources